On 08/24/2016 03:57 PM, Richard wrote:
> [Please do not mail me a copy of your followup]
>
> Cholo Lennon <
cholo...@hotmail.com> spake the secret code
> <npkq19$ibo$
1...@gioia.aioe.org> thusly:
>
>> Can I assume (in a portable sense) that /#include "some_header"/ will
>> always start its search from the same directory that the file that is
>> including it? (at least in g++ and VC++ this behavior is present)
>
> Not really. It depends on the search order specified by the
> implementation. So to answer your question you have to look at the
> documentation for the implementation you're using.
>
> For gcc, the documentation says that it searches the directory
> containing the header, then -iquote directories, then normal POSIX
> system directories.
> <
https://gcc.gnu.org/onlinedocs/cpp/Search-Path.html>
>
> For MSVC, the documentation says that it searches the directory
> containing the header, then directories containing currently open
> headers, then /I directories, then directories specified by the
> INCLUDE environment variable.
> <
https://msdn.microsoft.com/en-us/library/36k2cdd4.aspx>
>
> So for these two implementations, the behavior is as you describe.
>
> I didn't look up the docs on clang as it generally adopts the
> behavior of gcc for compatibility, but it could also use the MSVC
> algorithm when invoked with MS compatibility flags.
>