When I compile a very simple source file with gcc I don’t have to specify the path to standard include files such as stdio or stdlib.
How does GCC know how to find these files?
Does it have the /usr/include path hardwired inside, or it will get the paths from other OS components?
In order to figure out the default paths used by
gcc/g++, as well as their priorities, you need to examine the output of the following commands:The credit goes to Qt Creator team.
Here’s a breakdown of the flags:
-xselects the language,CorC++respectively-Emakes gcc to run the preprocessor only, so no compilation takes place-vprints all the commands run, which is the key to dumping the standard paths-is the "input file" to preprocess, as a convention-stands for stdin (or stdout, depending on the context);echo |feeds an empty string togccso effectively we preprocess an empty file generated on the flyHere’s a nice explaining it in more detail: https://explainshell.com/explain?cmd=echo+%7C+gcc+-xc+-E+-v+-