The only thing the standard says about the searching of files
included with #include "name"
and #include
<name>
is that when #include <name>
is
valid then #include "name"
is also valid (excepted if the
name contains a "). It doesn't even says that the names for the
#include <>
are file names.
This page aims to collect the behaviour of compilers.
Here are the behaviours I've observed or for which I've received precise information.
Excepted when the names are standard header names, the most common behaviour is that the names are file names and that those files are searched in the following directories:
#include ""
, in the directory of the file
containing the directive;While this behaviour is the most common, it is not possible to achieve it with the following compilers:
Visual C++ has nearly the same behaviour but looks for files
included with #include ""
in the directory of the file
containing the directive and in the directories of all the
files including this file (directly or indirectly) before searching
the user specified list of directories.
Some compilers allow to get the following search order:
#include ""
, in a list of directories given by the user;These compilers are:
One of them (Metrowerks CodeWarrior) allows to indicate for each of the directories given by the user that the search must be recursive, that is that the sub-directories are also searched.
Here are some behaviour for which I've not a precise description.
Some compilers look for files included with #include
""
in the directory where the compiler is launched and not in
the directory of the file containing the directive. According to
some, this is the standard behaviour on VMS but I don't remember so (I
may be wrong, it's a long time since I've used VMS last) and that's
not the case for the DECUS C preprocessor (whose sources are available
somewhere on the net).
If you have any information about the behaviour of common or rare preprocessor, I'm willing to include them here.