0

I came across the topic of the precompiled headers in C, so I started reading about it, in brief, the article(s) I read said that gcc will use precompiled header (h.gch) if there is one, otherwise normal header file(.h) will be used.

I just wanted to try it out and see if that actually happens with my code. So, I wanna know if there is any command in Linux(Ubuntu) to see what all files are being used by the GCC compiler while it is compiling your code. What I am thinking is, if the .h.gch file is used instead of .h files then it works how it should be and I get the concept of precompiled header files.

For example, if I do something like

gcc myCode.c

then gcc will definitely go to that file (myCode.c) and if myCode.c file includes a header file then that header file will also be touched/opened by gcc.

https://gcc.gnu.org/onlinedocs/gcc-5.1.0/gcc/Precompiled-Headers.html

This is from where I read about precompiled headers.

Mike Kinghan
  • 55,740
  • 12
  • 153
  • 182

1 Answers1

1

If you simply want to see what files are opened by gcc or any other process on Linux then you can use Strace.

strace -f -e open gcc myCode.c

amritanshu
  • 777
  • 13
  • 25