[previous] 3332 [next] The macro '%s' used in this '#if' or '#elif' expression is not defined.
Preprocessing

The conditional expression in this #if or #elif directive refers to a macro which has not been defined. The macro token will be replaced by the number 0. This is totally legitimate according to the ISO:C Standard but is not good practice because it could hide a mistake.

If it is anticipated that a macro may not always be defined, it is better to test for its existence (using #ifndef) and then, where necessary, #define its value explicitly.


/*PRQA S 2017,3211,3408 ++*/

#define M1 5

#if (M1 == 5)        /* OK - M1 is defined */
int x = 0;
#endif

#if (M2 == 5)        /* Message 3332 - unless M2 is defined externally */
int y = 0;
#endif

#ifndef M3           /* Test to determine if M3 is defined */
#define M3 0
#endif

#if (M3 == 5)        /* OK - M3 is defined */
int z = 0;
#endif


MISRA C:2012 Rules applicable to message 3332:

Rule-20.9  (Required) All identifiers used in the controlling expression of #if or #elif preprocessing directives shall be #define'd before evaluation


QA·C Source Code Analyser 8.1
MISRA C:2012 Compliance Module 1.0
© 2012 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index Contents