MISRA C++:2023 Rule 19.2.3
The '
or "
or \
characters and the /*
or //
character sequences shall
not occur in a header file name
Since R2024b
Description
Rule Definition
The '
or "
or \
characters and the /*
or //
character sequences
shall not occur in a header file name.
Rationale
You include header files in a source file by enclosing its name between the
delimiters <>
or ""
. Using the characters
'
, "
, /*
, or
//
between the delimiters <
and
>
is undefined behavior. Using the characters
'
, /*
, or //
between the
"
delimiters also results in undefined behavior. Depending on your
environment and compiler, using these characters in a header filer name might result in
unexpected behavior.
Avoid the characters '
, "
,
/*
, or //
in a header file name.
Polyspace Implementation
Polyspace® raises a violation of this rule if the name of a header file includes one of these characters:
'
"
/*
//
If you use the character "
between the delimiter
"
, Polyspace interprets the portion of the header name between two successive
"
delimiters as the header file name. For instance, in this
code,
#include "foo\".h"
foo\
as the header name. In such cases,
Polyspace does not raise a violation of this rule, but because the compiler looks
for a header file that does not exist, you might get a compilation warning.Troubleshooting
If you expect a rule violation but Polyspace does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Preprocessing Directives |
Category: Required |
Version History
Introduced in R2024b