Re: How to determine the directories from where "#include <.....>"
gets the header files?
On 18 mai, 04:01, pcs...@yahoo.com (Pablo Suarez) wrote:
When I code
then this header file is searched in the current directory.
Not with the compilers I use. The de facto standard is to first
look for it in the directory which contained the file containing
the header declaration.
But where does the compiler search the header file when I write
Where ever it wants to. In theory, at least, there may not even
be a file. (As far as the standard is concerned, you can only
use this form for the standard headers.)
According to the standard, the compiler has two different rules,
one for looking up "...", and another for looking up <...>, and
the second need not even be a file; the compiler could "know"
the contents of all of the standard headers, and simply
incorporate that knowledge directly. In addition, the standard
says that if lookup for "..." fails, the compiler must attempt
again as if it were <...>.
In practice, the rules are:
-- if the "header.hh" form is used, look in the directory
containing the file with the include, then
-- look in each of the directories specified by the -I or /I
options, in the order the options appeared, and finally
-- look in a number of predefined locations---under Unix, this
is typically some locations depending on where the compiler
is installed, plus /usr/include.
In practice, too, that's just a minimal set. A lot of compilers
have additional options or rules.
James Kanze (GABI Software) email:firstname.lastname@example.org
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34