This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Quotes and Brackets In Include Directives

> -----Original Message-----
> From: Tim Hollebeek []
> Sent: Wednesday, September 05, 2001 12:26 AM
> To: Eric Lemings
> Cc:
> Subject: Re: Quotes and Brackets In Include Directives
> > I always thought that:
> > 
> > #include <string.h>
> > 
> > would include the string.h header in the "system" include 
> path while:
> > 
> > #include "string.h"
> > 
> > would include a different string.h header file in the 
> "local" include
> > path.
> You thought wrong.  The relevant standards have always mandated that
> the "" search list be a superset of the <> include search list.
> Order is, IIRC, implementation defined.

Not quite :-)

The standard further specifies, IIRC and looking at the documents I hav
off-hand now, that the additional search places used for "" are searched
*before* the standard places. 

Traditionally (but this is implementation defined) these additional places
are just the directory of the including file. Beware, this is not the main
source file, but the file containing the #include directive.

This has interesting effects that may look surprising: if search list is
foo/ bar/, both contains xxx.h, bar contains yyy.h which '#include "xxx.h"',
then bar/xxx.h will be used, not foo/xxx.h, even as both are "system"
include directories :-)


> In particular, this means that having local include files with names
> that are the same as system headers is asking for trouble.  Various
> compilers can and do differ in which one you will get with various
> combinations of CWD, -I options, etc.
> -Tim

Bernard Dautrevaux
Microprocess Ingenierie
97 bis, rue de Colombes
Tel:	+33 (0) 1 47 68 80 80
Fax:	+33 (0) 1 47 88 97 85

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]