Include What You Use (IWYU) is a source analysis tool for C and C++ projects built on Clang. It examines header dependencies to determine whether source files directly include the declarations required by the symbols they use.
In large C and C++ projects, header dependencies can become difficult to maintain. Files may rely on declarations included indirectly through unrelated headers, while retaining other includes that are no longer necessary. IWYU identifies these relationships and recommends changes that make individual source files more self-contained.
The tool can analyse individual translation units or integrate with existing build workflows. It also supports compilation databases, allowing developers to examine entire projects using their normal compiler options.
IWYU provides recommendations for adding and removing includes, replacing suitable dependencies with forward declarations and cleaning up existing include directives. Developers should review its suggestions carefully, particularly in projects with unusual header structures or complex library dependencies.
This is free and open source software.
Key Features
- Analyses C and C++ source files to identify missing, unnecessary and indirect header dependencies.
- Recommends direct includes for symbols used by individual translation units.
- Identifies header dependencies that can be replaced with forward declarations.
- Provides separate recommendations for source files and their associated headers.
- Supports analysis of additional header files through configurable file patterns.
- Integrates with existing build systems using normal compiler options.
- Works with CMake through its native Include What You Use integration.
- Processes compilation databases using the iwyu_tool.py helper script.
- Includes fix_includes.py for applying suggested include changes automatically.
- Customisable handling of include comments and forward declarations.
- Supports IWYU pragmas to preserve includes, mark private headers and control dependency analysis.
- Custom header mappings help associate private declarations with their public headers.
- Compatible with Clang-based source analysis workflows.
- Cross-platform support – runs on Linux, macOS, and Windows.
Website: github.com/include-what-you-use/include-what-you-use
Support:
Developer: include-what-you-use contributors
License: University of Illinois/NCSA Open Source License
Include What You Use is written in C++. Learn C++ with our recommended free books and free tutorials.
Related Software
| C and C++ Linters | |
|---|---|
| OCLint | Static code analysis tool for improving quality and reducing defects |
| cpplint | Static code checker for C++ |
| CodeChecker | Platform for running static analysers and managing code defects |
| Uncrustify | Source code beautifer |
| Infer | Static analyser that detects bugs in Java, C and C++ code |
| Include What You Use | Source analysis tool for C and C++ projects built on Clang |
| Cppcheck | Static analysis tool for C/C++ code |
| flawfinder | Scans C and C++ source code for potential security weaknesses |
| clazy | Qt-focused static analyser that catches common C++ mistakes |
| ClangFormat | Code formatting tool |
| Clang-Tidy | Clang-based C++ “linter” tool |
| Smatch | Static analysis tool for finding defects in C code |
| Coccinelle | Semantic patching tool for analysing and transforming C code |
Read our verdict in the software roundup.
LinuxLinks helps you discover the best free and open source software for Linux. Explore our extensive collection of recommended applications, including alternatives to popular proprietary software.We also publish software reviews, Linux tutorials, hardware reviews, free programming books and articles covering the wider open source community. Browse our Linux resources to discover more. Know a useful free and open source Linux application we haven't covered? Suggest a program for inclusion. Has your software been featured on LinuxLinks? Display one of our Featured on LinuxLinks badges on your website or GitHub README. |


Please read our Comment Policy before commenting.