For the moment, my C codebases compile relatively quickly. However, I would like to utilise an informed approach to reducing the number of times a given header is re-processed.
I guess that being able to see reference counts would help me to do so. How would I do that?
Both CLang and GCC support the -H
option. It will dump into the console each header file included. Then, you can easily read these lines and analyze them to detect compiler bottlenecks.
From man gcc
:
-H
Print the name of each header file used, in addition to other normal activities. Each name is indented to show how deep in the#include
stack it is.Precompiled header files are also printed, even if they are found to be invalid; an invalid precompiled header file is printed with
...x
and a valid one with...!
.