How to determine where the header file is from?

How can I find out where g ++ was able to find the include file? Basically, if I

#include <foo.h> 

g ++ scans the search path using any inclusion options to add or change the path. But in the end, is there a way that I can tell the absolute path foo.h that g ++ decided to compile? Especially true if the set of search paths contains more than one foo.h.

There is not enough way to accomplish this ... is there a way to get g ++ to tell me what its final search path is after including the defaults and all options include?

+59
c ++ c gcc include g ++
Apr 29 2018-11-11T00:
source share
4 answers

This will give make dependencies that list the absolute paths of include files:

 gcc -M showtime.c 

If you do not want the system to include (i.e. #include <something.h> ), use:

 gcc -MM showtime.c 
+44
Apr 29 '11 at 17:02
source share
 g++ -H ... 

will also print the full path of the included files in a format that shows which header includes

+56
Sep 03 '13 at 13:16
source share

Proper use

 g++ -E -dI ... (whatever the original command arguments were) 
+4
Apr 29 '11 at 16:38
source share

If you use -MM or one of the related options ( -M , etc.), you only get a list of headers that are included without all the other preprocessor output (which you seem to get with the suggested g++ -E -dI ).

+3
Apr 29 2018-11-21T00:
source share



All Articles