Math-Linux.com

Knowledge base dedicated to Linux and applied mathematics.

Home > C++ > FAQ C++ > FAQ C++ - gcc/g++ > gcc / g++ find where a header file is included from

gcc / g++ find where a header file is included from

To list absolute paths of include files, use

-M

Instead of outputting the result of preprocessing, output a rule suitable for make describing the dependencies of the main source file. The preprocessor outputs one make rule containing the object file name for that source file, a colon, and the names of all the included files, including those coming from -include or -imacros command line options.

gcc  -M test.c

If you dont want the system includes like


#include <stdio.h>

then use

-MM

Like -M but do not mention header files that are found in system header directories, nor header files that are included, directly or indirectly, from such a header.


gcc  -MM test.c

Also in this section

  1. Build in release mode with full optimizations in gcc / g++
  2. Code that compiles with gcc but not g++
  3. Disable all gcc / g++ warnings
  4. g++ compilation option -Weffc++
  5. gcc / g++ find where a header file is included from
  6. gcc / g++ how to dump all preprocessor definitions
  7. gcc / g++ preprocessor flags for the compiler version number
  8. gcc /g++ Why some variables are not detected as not used during compilation?
  9. Undefined Symbol ___gxx_personality_v0