c - Use #define from macro -
this question has reply here:
how concatenate twice c preprocessor , expand macro in “arg ## _ ## macro”? 2 answersi have #define
d preprocessor constant called currentclass
. macro method
reads constant build method declaration current class.
#define currentclass foo #define method(x) \ currentclass ## _ ## x void method(bar)() { }
the preprocessor produces next result:
void currentclass_bar() { }
obviously, currentclass_bar
here should foo_bar
. next on other hand produces right result.
#define method(class, x) \ class ## _ ## x void method(foo, bar)() { }
for reason, method
can't concatenate constant currentclass
else. currentclass
lone produces desired foo
string.
any thought happening here?
you have expand twice
#define xx(x0,x1) x0 ## _ ## x1 #define x(x0,x1) xx(x0,x1) #define method(y) \ x(currentclass,y)
c c-preprocessor
No comments:
Post a Comment