I have a project in C that I need to modify and run. At some point, in a source file I have
#ifndef THE_FLAG
// declare important stuff
#endif
but, I don’t know where THE_FLAG is #included from. It is not defined in my project, and it is hidden somewhere in external library.
I tried gcc -M but it shows the headers, without information if it was included directly or somewhere higher in the include hierarchy.
The project is too complicated to track all the dependencies by hand. It is build with ./configure && make.
Question: how to track this external dependency?
Try compiling with
gcc -E. This will tell gcc to stop at the preprocessing stage. As part of that, it will tell you where all the#defines came from.Note that this will create a text file, not a
.ofile.