[previous] MISRA C:2012  Rule-20.8:  (Required) [next] The controlling expression of a #if or #elif preprocessing directive shall evaluate to 0 or 1

Amplification:

This rule does not apply to controlling expressions in preprocessing directives which are not evaluated. Controlling expressions are not evaluated if they are within code that is being excluded and cannot have an effect on whether code is excluded or not.

Example Code:


#include "misra.h"
#include "m3cmex.h"

#define FALSE 0
#define TRUE 1
#define A 10
#define B 20

#if FALSE                       /*      */      /* Compliant */
#endif

#if 10                          /*      */      /* Non-compliant */
#endif

#if !defined(X)                 /*      */      /* Compliant */
#endif

#if A > B                       /*      */      /* Compliant */
#endif

extern int16_t rule_2008( void )
{
    return 1;
}


No QAC messages cover this rule.



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