AutosarC++17_10-A16.2.1

The ‘, “, /*, //, characters shall not occur in a header file name or in #include directive

Required inputs: IR

Rationale

It is undefined behavior if the ’, ", /*, //, \\ characters are used in #include directive, between < and > or “ ” delimiters.

Example
// $Id: A16-2-1.cpp 271687 2017-03-23 08:57:35Z piotr.tanski $

//   #include   <directory/headerfile.hpp> // Compliant
//   #include   <headerfile.hpp> // Compliant
//   #include   "directory/headerfile.hpp" // Compliant
//   #include   "headerfile.hpp" // Compliant
//   #include   <directory/*.hpp> // Non-compliant
//   #include   <header’file.hpp> // Non-compliant
//   #include   <"headerfile.hpp"> // Non-compliant
//   #include   <directory\\headerfile.hpp> // Non-compliant
See Also
  • MISRA C++ 2008 [6]: Rule 16-2-4 The ’, ", /* or // characters shall not occur in a header file name.
  • MISRA C++ 2008 [6]: Rule 16-2-5 The \character shall not occur in a header file name.

Possible Messages

Key

Text

Severity

Disabled

nonstandard_include_character

Non-standard character in #include directive

None

False

Options

check_quotation_mark

check_quotation_mark : bool = True

Whether system includes should be checked for containing a ".
 

forbidden

forbidden : set[str] = {"'", '/*', '//', '\'}

The substrings to check for. " will be added for system-includes.