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