Is there a way to define a macro checking if another macro is defined and non-zero or respectively not defined or defined as zero?
I recently ran into the problem that different people define their macros in a different way if they are used as flags. While compiling some define their macro without a value (eg. -DDEBUG
) and some set it to non-zero (eg. -DDEBUG=1
).
I actually found code similar to it: (defined(macro ## _SET) && (macro ## _SET))
. The solution for this to work is the concatenation ##
which prevents the macro expansion. Is there a way around it?
Environment
GNU Arm Embedded Toolchain (arm-none-eabi-*
) with GNU ISO C99 (std=gnu99
).