Using C++ preprocessor directives, is it possible to test if a preprocessor symbol has been defined but has no value? Something like that:
#define MYVARIABLE
#if MYVARIABLE==0
My answer must be at least 30 chars, so that should do it!
I haven't seen this solution to the problem but am surprised it is not in common use . It seems to work in Xcode Objc. Distinguish between "defined with no value" and "defined set 0"
#define TRACE
#if defined(TRACE) && (7-TRACE-7 == 14)
#error TRACE is defined with no value
#endif
You can't since the preprocessor can only check for a numeric value. Your string compare is not covered by preprocessor syntax.