Skip to main content

IAR Embedded Workbench for RISC-V 3.40

MISRAC++2008-16-0-1

In this section:
Synopsis

(Required) #include directives in a file shall only be preceded by other preprocessor directives or comments.

Enabled by default

No

Severity/Certainty

Low/Low

lowlow.png
Full description

#include directives were found that are not first in the source file. This check is identical to MISRAC2004-19.1, MISRAC2012-Rule-20.1, MISRAC++2023-19.0.3.

Coding standards
MISRA C:2004 19.1

(Advisory) #include statements in a file should only be preceded by other preprocessor directives or comments.

MISRA C:2012 Rule-20.1

(Advisory) #include directives should only be preceded by preprocessor directives or comments

MISRA C++ 2023 19.0.3

(Advisory) #include directives should only be preceded by preprocessor directives or comments

Code examples

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

void example(void) {}
int x;
#include <cstdio>
void example(void) {}

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

void example(void) {}
#include <cstdio>
void example(void) {}