I compile my C++ code using gcc (4.6.3), and want the compiler to print all the includes it uses. In MS VS it is done simply by adding a /showIncludes flag, and the output looks like this:
1> File.cpp
1> including file : A.h
1> including file : B.h
1> including file : C.h
1> including file : B2.h
Is there such option in gcc?
Thanks!!!
gcc has a -v flag. That will show you exactly what files it is including, as well as where it is searching for includes.
If you want the complete dependency tree, then use the -M flag. This is used to list not only the files directly included by gcc, but the files included by those as well. Using plain "gcc -M" will list everything, including the entire tree of standard library includes. If you are just analyzing your own code base, try "gcc -MM" to limit the inclusion of system files.
The search term you want is "dependency", as most of these options are commonly used in the gcc world to build machine readable files (usually with a *.d extension) for the Make utility to use. Try googling that if you need to drill down to more detail on this family of options.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With