Our dev environment makes heavy use of directories with locally modified headers that should be seen by the compiler instead of the "committed" "repository" versions.
If header A includes header B, gcc looks for B in the same directory A was in and does not obey the seach path.
So we used the -I-
option on gcc to prevent that. Gcc will strictly follow the hierarchy of the include-path then.
As with gcc4 the -I-
option is deprecated and repaced by -iqoute
.
I can't figure out how to get the same behaviour with the -iquote
option because I think it is lacking the side-effect of disabling the search in the "current" directory.
see http://gcc.gnu.org/onlinedocs/cpp/Invocation.html#Invocation
Any ideas how to achieve the same behaviour?
GCC looks for headers requested with #include " file " first in the directory containing the current file, then in the directories as specified by -iquote options, then in the same places it would have looked for a header requested with angle brackets. For example, if /usr/include/sys/stat.
For include files that are specified as #include "path-spec" , directory search begins in the directory of the parent file and then proceeds through the directories of any grandparent files. That is, the search begins relative to the directory that contains the source file that's being processed.
Most standard headers are stored in /usr/include . It looks like stdbool. h is stored somewhere else, and depends on which compiler you are using. For example, g++ stores it in /usr/include/c++/4.7.
AFAIK, there is no other way to desactivate the behaviour you are complaining about other than using the form #include <foo.h>
instead of #include "foo.h"
in your code.
ISTR, but I've failed to find a reference, that the rationale for deprecating -I-
without providing another mechanism for that aspect is that libraries commonly use the form #include "foo.h"
to ensure they get their own internal header file foo.h
and the use of -I-
broke them in some cases if someone else happened to have a file similarly named earlier on the search path.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With