Why is this an issue?
The #include
directive is a preprocessor directive that tells the compiler to insert the contents of a file in the source code.
However, the standard only allows the #include
directive to be followed by angle brackets (<filename.h>
) or double
quotes ("filename.h"
).
If the #include
directive contains macro names, the result of their expansion must also follow this rule:
#define HEADER "filename.h"
#include HEADER // Compliant
The behavior is undefined if neither angle brackets nor double quotes follow the #include
directive.
Resources
External coding guidelines
- MISRA C:2004, 19.3 - The #include directive shall be followed by either a <filename> or "filename" sequence.
- MISRA C++:2008, 16-2-6 - The #include directive shall be followed by either a <filename> or "filename" sequence.
- MISRA C:2012, 20.3 - The #include directive shall be followed by either a <filename> or "filename" sequence