This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C extension to catch function return type


Hi all,

I'd like to know if there is any way, even using gcc extensions,
to syntactically "catch" what is the return type (and the list
of formal arguments) of a function in which I am.

Also, in case there is no way, I'd like to know how difficult would
be to introduce a couple of keywords, like __func_return_type__
and __func_args__, that fulfill such requirements, and behave
similarly to the "__func__" identifier from the language perspective.

Such a construct would be useful together with the
__builtin_apply_args() and related builtins, as shown
in the example below:

long f(int x, int y)
{
 void *p_args = __builtin_apply_args();
 void *p_rv;
 /* forward nested-function declaration */
 __func_return_type__ internal(__func_args__);

 /* add something before */
 p_rv = __builtin_apply(internal, p_args);
 /* add something after */
 __builtin_return(p_rv);

 __func_return_type__ internal(__func_args__)
 {
   /* actual body of function f() comes here */
 }
}

In the example, I'm "wrapping" the actual code of
function f() by using a nested function, so that the
code following it is always executed, even if return...
statements are used in the middle.
Of course, it would be advantageous to place such
code segments inside appropriately designed macros.

Many thanks in advance.

Regards,

   Tommaso
--
Tommaso Cucinotta, Computer Engineering PhD, Researcher
ReTiS Lab, Scuola Superiore Sant'Anna, Pisa, Italy
Tel +39 050 882 024, Fax +39 050 882 003
http://feanor.sssup.it/~tommaso


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]