i have 2 macros in c code helps me compose name of variables. example, consider following:
#define macroa(name) a_##name #define macrob(name) b_##name void *macrob(macroa(object));
so, i'm trying declare variable called b_a_object
. however, doesn't work , compiler throws me message:
object.c:27:21: error: parameter list without types allowed in function definition void *macrob(macroa(object)); ^ object.c:26:26: note: expanded macro 'macrob' #define macrob(name) b_##name ^
so, seems preprocessor not taking result of macroa(object)
, considering expression tries make b_macroa(object)
. so, have make preprocessor consider result of macro passed macro?
the concatenation operator acts weird. concatenates first , evaluates later:
void *macrob(macroa(object)); // original line void *b_macroa(object); // becomes this, nothing more expand
you can solve way:
#define conc(a,b) ## b #define macroa(name) conc(a_, name) #define macrob(name) conc(b_, name)
Comments
Post a Comment