order of headers lookup

Dima Sorkin dsorkin@techunix.technion.ac.il
Tue Aug 2 12:08:00 GMT 2005


Hi.
 This feature of gcc seems strange to me:

Consider a directory structure of a tiny project:
/main.cpp (#include "foo.hpp" )
/d1/bar.hpp
/d2/foo.hpp (#include "bar.hpp")
/d2/bar.hpp

then compiling
 > g++ -I d1 -I d2 main.cpp -o main
will include /d2/bar.hpp instead of /d1/bar.hpp as I expected
( I expected so because "d1/" is listed first in "-I" options).

Such a behaviour of g++ limits the use of "sandboxes" in c++
projects ( consider the /d1/ directory as a sandbox of a real project).

Hope I don't miss something.

Thank you.
 Dima.



More information about the Gcc-help mailing list