Tool to track #include dependencies

Agnel Kurian picture Agnel Kurian · Sep 3, 2008 · Viewed 71.5k times · Source

Any good suggestions? Input will be the name of a header file and output should be a list (preferably a tree) of all files including it directly or indirectly.

Answer

KeithB picture KeithB · Sep 3, 2008

If you have access to GCC/G++, then the -M option will output the dependency list. It doesn't do any of the extra stuff that the other tools do, but since it is coming from the compiler, there is no chance that it will pick up files from the "wrong" place.