AutosarC++17_10-M16.2.3

Include guards shall be provided

Required inputs: IR

Every header file should have an include guard. This ensures that including the file multiple times into the same compilation unit (e.g. indirect inclusions through other headers) do not cause compiler errors due to duplicate type definitions.

Include guards also help reduce compilation time, as compilers that recognize the include guard can avoid repeatedly scanning the header file.

Example
#ifndef DIR_FILE_H
#define DIR_FILE_H

...

#endif

The identifiers used for include guards must be unique. If header file names are not necessarily unique in your project, include the directory name in the identifier.

Note

For legal reasons, this rule’s description is not part of the public documentation.