Useless include
Description
This defect occurs when you do not use an included header.
For instance, 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.
If an object is used inside a nested macro, Polyspace can miss the usage. As a result,
Polyspace might flag the include
that declares the object as
USELESS_INCLUDE
.
Risk
Unnecessary file dependencies slow the build speed of the project. To improve build speed, remove include directives that are not used.
Fix
Remove the unused include directive.
Examples
Result Information
Group: Good Practice |
Language: C | C++ |
Default: Off |
Command-Line Syntax:
USELESS_INCLUDE |
Impact: Low |