* order of headers lookup
@ 2005-08-02 12:08 Dima Sorkin
2005-08-02 14:15 ` Eljay Love-Jensen
[not found] ` <4a618d0805080205273aeb3054@mail.gmail.com>
0 siblings, 2 replies; 3+ messages in thread
From: Dima Sorkin @ 2005-08-02 12:08 UTC (permalink / raw)
To: gcc-help
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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: order of headers lookup
2005-08-02 12:08 order of headers lookup Dima Sorkin
@ 2005-08-02 14:15 ` Eljay Love-Jensen
[not found] ` <4a618d0805080205273aeb3054@mail.gmail.com>
1 sibling, 0 replies; 3+ messages in thread
From: Eljay Love-Jensen @ 2005-08-02 14:15 UTC (permalink / raw)
To: Dima Sorkin, gcc-help
Hi Dima,
#include "" checks current directory first.
Use #include "d1/bar.hpp" in your foo.hpp.
HTH,
--Eljay
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: order of headers lookup
[not found] ` <4a618d0805080205273aeb3054@mail.gmail.com>
@ 2005-08-04 6:48 ` Dima Sorkin
0 siblings, 0 replies; 3+ messages in thread
From: Dima Sorkin @ 2005-08-04 6:48 UTC (permalink / raw)
To: gcc-help
Quoting Arturas Moskvinas :
> > 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).
>
> It is from C preprocessor manual:
> #include "file"
> This variant is used for header files of your own program. It
> searches for a file named file first in the directory containing the
> current file, then in the same directories used for <file>.
>
> So, i think you should use #include <bar.hpp> to get your wanted behavior...
Yes, it works.
Thank you.
Dima.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-08-04 6:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-02 12:08 order of headers lookup Dima Sorkin
2005-08-02 14:15 ` Eljay Love-Jensen
[not found] ` <4a618d0805080205273aeb3054@mail.gmail.com>
2005-08-04 6:48 ` Dima Sorkin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).