I've got some big C programs, and I would like to know when I'm compiling this program, which header files are actually included...
The simplest solution would be to print the preprocessed code and look but do you know if there's a way to compile and at the same time showing what header files are included?
GCC looks for headers requested with #include " file " first in the directory containing the current file, then in the directories as specified by -iquote options, then in the same places it would have looked for a header requested with angle brackets.
Most standard headers are stored in /usr/include . It looks like stdbool. h is stored somewhere else, and depends on which compiler you are using. For example, g++ stores it in /usr/include/c++/4.7.
gcc -I adds include directory of header files.
If you use both this option and the -isysroot option, then the --sysroot option applies to libraries, but the -isysroot option applies to header files. The GNU linker (beginning with version 2.16) has the necessary support for this option.
Use the -M option to output the dependencies. Use -MD to generate and compile. Use -MF to redirected to a file.
Also -MM allow ignoring the system file in the dependencies list.
gcc ... -M -MF <output_file> # generate dependencies
gcc ... -MD -MF <output_file> # compile and generate dependencies
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