Why is this an issue?
An attempt to use an undefined identifier may elicit a warning from the preprocessor. Or it may not; the preprocessor may simply assume that the
undefined token has a value of 0.
Therefore macro identifiers should not be used in preprocessor directives until after they have been defined, and this limited usage should be
enforced with the use of definition tests.
Noncompliant code example
#if x > 0 /* x assumed to be zero if not defined */
#ifdef y /* Okay; y is not evaluated */
#if y > 0 /* Okay; y must be defined to reach this point */
#define x 10
#if x > 0
#if defined ( y ) && ( y > 0 ) /* more compact form, same result as before */
- MISRA C:2004, 19.11 - All macro identifiers in preprocessor directives shall be defined before use, except in #ifdef and #ifndef preprocessor
directives and the defined() operator.
- MISRA C:2012, 20.9 - All identifiers used in the controlling expression of #if or #elif preprocessing directives shall be #define’d before