AUTOSAR C++14 Rule A16-2-2
Description
Rule Definition
There shall be no unused include directives.
Rationale
Unused include directives unnecessarily increase the code base size and introduce dependencies, which slows down the compilation process. To avoid this issue, remove unused include directives.
Remove unused include directives from the code.
Polyspace Implementation
Polyspace® reports a violation when a source file includes a header file that contains declarations of symbols that are not used in the source file. This rule checker does not check any external libraries.
Polyspace considers an include directive to be unused when you do not:
Invoke macros defined in the included file or the included file's includes.
Use data types defined in the included file or the included file's includes.
Call or use references to an object or function defined in the included file or the included file's includes.
Use an externally visible object provided by the included file outside of the file.
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, Automated |
Version History
Introduced in R2021b