Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gcc - how to find path of header include file

Do we have any option in gcc to find from where a particular file header is included. I have the following scenario :

file_1.h : declare type of type_1

file_2.h :

type_1 var;

I want to check where was file_1.h included in the library that i am creating.

like image 516
Dexter Avatar asked Oct 12 '12 08:10

Dexter


1 Answers

gcc has an option -M:

-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.

If you do, gcc -M filename.c, it'll list out all headers. Same with g++.

like image 77
P.P Avatar answered Nov 12 '22 19:11

P.P