Skip to main content

IAR Embedded Workbench for RX 5.20

MISRAC2012-Rule-20.14

In this section:
Synopsis

(Required) All #else, #elif, and #endif preprocessor directives shall reside in the same file as the #if, #ifdef, or #ifndef directive to which they are related.

Enabled by default

Yes

Severity/Certainty

Medium/Medium

mediummedium.png
Full description

Unbalanced #if/#endif preprocessor directives were found.

Note: This check is not part of C-STAT® but detected by the IAR compiler.

Coding standards
MISRA C:2012 Rule-20.14

(Required) All #else, #elif and #endif preprocessor directives shall reside in the same file as the #if, #ifdef or #ifndef directive to which they are related

Code examples

The following code example fails the check and will give a warning:

#ifdef HAS_INCLUDE_H
#include "include.h"
/* include.h content:

#endif
*/

The following code example passes the check and will not give a warning about this issue:

#ifdef HAS_INCLUDE_H
#include "include.h"
#endif