Skip to main content

IAR Embedded Workbench for RX 5.20

MISRAC++2008-16-2-3

In this section:
Synopsis

(Required) Include guards shall be provided.

Enabled by default

Yes

Severity/Certainty

Low/Low

lowlow.png
Full description

Header files without #include guards were found. This check is identical to MISRAC2004-19.15, MISRAC2012-Dir-4.10, MISRAC++2023-19.2.1.

Coding standards
MISRA C:2004 19.15

(Required) Precautions shall be taken in order to prevent the contents of a header file being included twice.

MISRA C:2012 Dir-4.10

(Required) Precautions shall be taken in order to prevent the contents of a header file being included more than once

MISRA C++ 2023 19.2.1

(Required) Precautions shall be taken in order to prevent the contents of a header file being included more than once

Code examples

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

#include "unguarded_header.h"
void example(void) {}

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

#include <stdlib.h>
#include "header.h"	/* contains #ifndef HDR #define HDR ... #endif */
void example(void) {}