Adding a path to the end of the gcc search path

I see that adding the path to the gcc search path can be done using the -I flag. However, when using -v, I see that the path is searched first.

Is there anyway the search path that I added, the search at the very end?

+7
gcc linux
source share
3 answers

The -idirafter allows you to specify the include directory for review only after all the usual -I directories and standard system directories. This is described here:

https://gcc.gnu.org/onlinedocs/cpp/Invocation.html#Invocation

-idirafter dir

Find the dir for the header files, but do it after all the directories specified with -I are exhausted and the standard system directories are exhausted. dir is considered as a system directory. If dir starts with = , then = will be replaced with the sysroot prefix; see --sysroot and -isysroot .

+5
source share

There is an explanation in SO: Manipulating the search path for the included files , and also here that can help you.

All three methods from above are mentioned in the related SO record.

+2
source share

Use the -idirafter option to add a directory to the end of the include search path.

+1
source share

All Articles