Possible Duplicate:
#ifdef inside #define
How do I use the character "#" successfully inside a Macro? It screams when I do something like that:
#define DO(WHAT) \
#ifdef DEBUG \
MyObj->WHAT() \
#endif \
You can't do that. You have to do something like this:
The
do { } while(0)
avoids empty statements. See this question, for example.How about:
It screams because you can't do that.
I suggest the following as an alternative:
It seems that what you want to do can be achieved like this, without running into any problems:
Btw, better use the
NDEBUG
macro, unless you have a more specific reason not to.NDEBUG
is more widely used as a macro that means no-debugging. For example the standardassert
macro can be disabled by definingNDEBUG
. Your code would become:You can do the same thing like this: