MISRAC2012-Dir-4.10
In this section:
Synopsis
(Required) Precautions shall be taken in order to prevent the contents of a header file being included more than once
Enabled by default
Yes
Severity/Certainty
Low/Low

Full description
Header files were found without #include guards. This check is identical to MISRAC2004-19.15, MISRAC++2008-16-2-3, 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++ 2008 16-2-3
(Required) Include guards shall be provided.
- 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) {}