CLion
 
Get CLion
You are viewing the documentation for an earlier version of CLion.

Inspection: Unused include directive

Last modified: 26 October 2023

Needless header files included in your code slow down the compilation and can pollute global namespace or even cause prepossessing collisions. Such includes add unnecessary dependencies, making your code harder to explore and maintain (for example, you will see a lot of irrelevant results in code completion).

The Unused Include Directive inspection detects the #include directives that are not required and can be safely removed:

Unused Includes inspection

The inspection does not warn you about the includes in source files with compilation errors. Also, it checks only the headers that contain #pragma once or header guards - files with none of them are always marked as used.