Reputation: 11476
I am trying to "arm" compile a C file,it includes lot of header files recursively..i am trying to find the list of these header files..is there a easier way to find the list of all the header files it includes?
Upvotes: 12
Views: 9476
Reputation:
As per http://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html#Preprocessor-Options -H and -M option are useful for this purpose.
Another option is to use http://www.doxygen.nl/ and generate documentation of your project, after that you can check it to see file dependencies :), it is preferred because it supports many languages: C, C++, Objective-C, C#, PHP, Java, Python, IDL (Corba and Microsoft flavors), FORTRAN, VHDL, Tcl.
Upvotes: 2
Reputation: 26164
You can use the GCC C preprocessor with it's option to dump a list of headers recursively included:
cpp -M
That will show you all headers included.
You will probably need to give it the roots of all include directories used in your regular build. Run it iteratively, adding more include paths until the errors stop.
The full form of this command in this usage is:
cpp -M [-I include_directory *] path_to_c_file.c
Upvotes: 15
Reputation: 202098
Most compilers have switch to make them just preprocess the file. What means among other that they expand all #include
's into an actual code. And usually they do include a comment (proper C comment) on the line of original include. So you can then search the resulting preprocessed code for all such comments to collect all included headers.
Upvotes: 0