I have a macro, SOME_MACRO
. It takes an argument.
Definition of SOME_MACRO
:
#define SOME_MACRO(arg) __SOME_MACRO(arg)
Further I want __SOME_MACRO(arg)
to expand to "ABC"
if arg
is 0
. And if arg
is not zero, __SOME_MACRO(arg)
should expand to "DEF"
Suppose I call with argument 0, that is: SOME_MACRO(0)
I need to test at preprocessing time, whether the argument is zero or not.
#if <argument is zero> // line 1
#define __SOME_MACRO(arg) "ABC"
#elif
#define __SOME_MACRO(arg) "DEF"
#endif
My question is: What should be at line 1?
Taking an example:
SOME_MACRO(2)
should expand to "DEF"
SOME_MACRO(0)
should expand to "ABC"