Exploring GCC's Default Include Directories
When compiling a C or C program, developers often rely on standard include files without explicitly specifying their paths. This raises the question: how does GCC locate these files?
To determine the default paths and their priorities, execute the following commands:
echo | gcc -xc -E -v -
for C, or
echo | gcc -xc++ -E -v -
for C .
The output of these commands contains a wealth of information, including the paths used by GCC.
Flags Breakdown:
Path Priority:
The output displays the paths in descending order of priority, with the highest-priority path listed first. This order determines which path GCC will search for include files first.
Credit:
Special thanks to the Qt Creator team for providing this insightful method.
Additional Resources:
For further explanation, refer to the following resource:
The above is the detailed content of How Does GCC Find Standard Include Files?. For more information, please follow other related articles on the PHP Chinese website!