Tools for managing C/C++ #includes: Formatting, sorting, exploring, pruning.
Include Toolbox consists of 4 different tools. All of them are only applicable to VC++ projects.
[Command] Include Formatter
Tools in Detail
Select a group of includes, right click, select "Format Selected Includes"
The behavior of this command is controlled by various options which can be configured in Tools>Options>Include Toolbox>Include Formatter:
All operations are performed in the order in which they occur on the option page.
Trial and Error Include Removal
The name says it all: This tool will try to remove an include, recompile, see if it works and proceed to the next one accordingly.
Obviously the results of this tool are far from optimal and the process can take a while.
The exact behavior of this command can be controlled in Tools>Options>Include Toolbox>Trial and Error Include Removal:
To suppress removal of a single include, add a comment to its line containing
Since 3.2.47 works for header files as well.
Include Toolbox with an integration of the free Include-What-You-Use. By default (see Tools>Options>Include Toolbox>Include-What-You-Use) it is downloaded together with a VC++ specific mapping file from this github repository upon first use (and whenever there is a newer version available in this repository). New version is automatically built and shipped every month.
Again, it can be activated by right clicking on a C++ Code file in a VC++ document. The Option page exposes most of IWYU's command line options and provides the option to directly apply the results. The complete output will be displayed in the Include Toolbox output window.
IWYU often does not work as expected - for more information look at the official docs.
IWYU has several pragmas, described at Pragmas, e.g.
Since 3.0.0: Added mapper support. Maps produced with it are used to make results better, as it describes all include files within mapped file.
Added cheap and precise modes: cheap mode copies contents of IWYU output, may be undesirable, as it does not account forward declarations, but it is fast. Presice mode uses custom LL1 partial parser, which reads all the information from file and output, combining all the possibilities it allows for additional steps:
There is a BETA feature of IWYU usage with several files:
It is useful for example with several .cpp files, when you are sure, that headers included are fully correct.
Map Generator for Include-What-You-Use [beta]
The feature is tested, but it is useful even within large projects. It makes results of IWYU better. Works only on header files.
It gets all the #include declarations and writes them as they are to the specified mapping file. Combining several of those files are done using
Configuration is on Tools>Options>Include Toolbox>Include Mapper page.
Mapper has one option, that specifies separator you would like to use, quotes or angle brackets. This option maps opposite choice as a private header, ultimately forsing IWYU to choose your vision of the file.
To specify relative index use Relative File Prefix option. e.g. C:\users\map\a.h with prefix C:\users will write <map/a.h> to the final map.
Include Graph [beta]
Partially restored functionality of include graph. The Graph window is controlled by the
The command opens a window with lazy parsed #includes. The file names are expandable only if the file described is present in project directory or in any of the additional directories. Graph includes can be navigated by double clicking the item in a graph. This will open the file which has that include line in it.
Options are not working right now. DGML save command will be added in future releases.
The graph is not stable, searching for bugs or inconsistensies. Issues pointing inconsistensies are welcome.
Optimal Usage Pattern
The IWYU itself is far from perfect, TAEIR also, but combinig those tools and Mapping capabilities with other maps, provided by IWYU repo and defaults the results will be just good enough.