I have confusion on following c code
#define MACRO (xx) \
foo(xx)
...
#ifdef A
return MACRO(a);
#endif
...
The source can not compile. But when I change definition to
#define MACRO \
foo(a)
So if I want to use MACRO with argument in this case, how should I do? Thanks..
Remove the space between
MACROand(xx).If you leave the space there, the preprocessor doesn’t treat
(xx)as the argument, but as part of the expansion. So whenever it seesMACRO, it replaces it with(xx) foo(xx).