AutosarC++19_03-A16.2.3¶
An include directive shall be added explicitly for every symbol used in a file
Required inputs: IR
| Level | required |
|---|---|
| Target | implementation |
| Enforcement | non-automated |
Rationale
All header files that define types or functions used in a file should be included explicitly.
The actual header to include depends on the specification of the library/component used.
Exceptions
Types defined via forward declarations do not violate this rule.
Example
// $Id: A16-2-3.hpp 319944 2018-05-21 09:00:40Z ilya.burylov $
#ifndef HEADER_HPP
#define HEADER_HPP
#include <array>
#include <cstdint>
class B; // Compliant - type B can be included using forward declaration
class OutOfRangeException
: public std::out_of_range // Non-compliant - <stdexcept> which defines
// out_of_range included
// implicitly through <array>
{
public:
using std::out_of_range::out_of_range;
};
class A
{
public:
// Interface of class A
private:
std::array<std::uint32_t, 10>
mArray; // Compliant - <array> included explicitly
B* mB;
std::int32_t mX; // Compliant - <cstdint> included explicitly
};
#endif
See Also
- none
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
missing_include |
Explicit include directive for symbol ‘{}’ is missing. |
None |
False |
missing_include_macro |
Explicit include directive for macro ‘{}’ is missing. |
None |
False |
Options¶
This rule shares the following common options: confidence, exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
allow_inclusion_through_own_header¶
allow_inclusion_through_own_header : bool = False
internal_header_patterns¶
internal_header_patterns : set[str] = set()
internal_symbol_patterns¶
internal_symbol_patterns : set[str] = set()