Using typeof in function parameter list?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm trying to build some macros that will define some structures, forward declare some functions, declare some other functions (including function bodies, etc.). I'm running into a problem though...

My macro takes a number of arguments, one of which is a field name in a previously defined struct (whose name is also passed to the macro). I want to define some functions that accept parameters of the same type as this field, so I try to do this:

#define TEST_MACRO(structtype, fieldname) \
struct structtype __dummy; \
static int foo_function(typeof(_dummy.fieldname) param1, typeof(_dummy.fieldname) param2);


Unfortunately, this produces "parse error before (" messages. I can use typeof lots of other places, but can't seem to use it to define the parameters for a function.

I have been successful in using a typedef inside my macro to create a new type name for the desired type, and then using that new type name for the function parameters, but that method requires that the function's real declaration also use the same typedef, which I was trying to avoid.

According to the GCC docs, the "typeof" operator is supposed to be able to be used anywhere the type name itself could be used... is this a bug?

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux