Should a macro used in #if be defined?
In a preprocessing directive such as this, if the macro is not defined, it is treated as 0
.
That is guaranteed by the language.
You can rely on there not being a compilation failure.
Here's the C++ wording:
[cpp.cond]/11
: After all replacements due to macro expansion and evaluations of defined-macro-expressions, has-include-expressions, and has-attribute-expressions have been performed, all remaining identifiers and keywords, except fortrue
andfalse
, are replaced with the pp-number0
, and then each preprocessing token is converted into a token. [..]