[previous] MISRA-C:2004  Rule  19.16:  (Required) [next] Preprocessing directives shall be syntactically meaningful even when excluded by the preprocessor.
When a section of source code is excluded by preprocessor directives, the content of each excluded statement is ignored until a #else, #elif or #endif directive is encountered (depending on the context). If one of these excluded directives is badly formed, it may be ignored without warning by a compiler with unfortunate consequences.

The requirement of this rule is that all preprocessor directives shall be syntactically valid even when they occur within an excluded block of code.

In particular, ensure that #else and #endif directives are not followed by any characters other than white-space. Compilers are not always consistent in enforcing this ISO requirement.

#define AAA 2
...
int foo( void )
{
    int x = 0;
    ...
#ifndef AAA
    x = 1;
#else1                      /* Not compliant */
    x = AAA;
#endif
    ...
    return x;
}


QAC messages that encompass this guideline:

3115 Unrecognized preprocessing directive has been ignored because of conditional inclusion directives.



(c) The Motor Industry Research Association, 2004
QA C Source Code Analyser 8.1.2
MISRA-C:2004 Compliance Module 3.2
© 2013 Programming Research
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index Contents