Why is this an issue?
Include guards, wrapping around the entire content of a header file, are a best practice that ensure that no matter how many times the header is
actually included in a translation unit, its content will only be seen once.
The include guard pattern is made up of four parts:
-
#ifndef
at the top of the file, with a unique macro name (usually the name relates to the name of the file, to ensure uniqueness).
-
#define
with the same macro name.
- The content of the file
-
#endif
at the end of the file
The rule raises an issue when the name in the second part differs from the name in the first (usually because of a typo or a copy/paste issue).
Noncompliant code example
#ifndef MYFILE_H
#define MY_FILE_H // Noncompliant
//...
#endif
Compliant solution
#ifndef MYFILE_H
#define MYFILE_H
//...
#endif