MISRA C++:2008 Rule 16-2-3

Include guards shall be provided

Description

Rule Definition

Include guards shall be provided.

Polyspace Implementation

The checker raises a violation if a header file does not contain an include guard.

For instance, this code uses an include guard for the #define and #include statements and does not violate the rule:

// Contents of a header file
#ifndef FILE_H

#define FILE_H
#include "libFile.h"

#endif

Troubleshooting

If you expect a rule violation but do not see it, refer to Coding Standard Violations Not Displayed.

Check Information

Group: Preprocessing Directives
Category: Required
Introduced in R2013b