Why warn about #include_next in system headers?

Zack Weinberg zackw@Stanford.EDU
Tue Feb 6 00:35:00 GMT 2001


On Tue, Feb 06, 2001 at 08:23:40AM +0000, Neil Booth wrote:
> Alexandre Oliva wrote:-
> 
> > > Hmm, does -I/usr/include qualify for 2)?
> > 
> > Yep.  -isystem is the way to tell GCC to search a certain directory as
> > a system header.  -I is for non-system headers.
> 
> Thanks Alexandre - I was confused by CPP's output.  Looking at the
> source code in cppinit.c, maybe this has uncovered a bug.
> 
> If I execute, to test the effect of -I,
> 
> cpp -I/usr /tmp/test.c /dev/null -v
> 
> I get
> 
> #include "..." search starts here:
> #include <...> search starts here:
>  /usr
>  /usr/local/include
>  /usr/local/lib/gcc-lib/i586-pc-linux-gnu/2.97/include
>  /usr/local/i586-pc-linux-gnu/include
>  /usr/include
> 
> This is what was confusing me.  The /usr appears after the <...> in
> the list - I expected it to be under the "...".  Looking at cppinit.c,
> I notice that *nowhere* calls append_include_chain with "QUOTE" as the
> include chain to put the path on (i.e. we could eliminate the QUOTE
> enumeration constant).

You've forgotten -I-.

> This looks fishy to me, Zack.  Is it right and I'm wrong in expecting
> -I to put it under the "..." QUOTE path?

-I has always inserted at the head of the <...> path.  The only way to
get anything between "..." and <...> in that list is -I- (which I
doubt ever gets used).

The implicit entry for the "directory of the current file" is on the
"..." search path but not the <...> path, but we don't mention that in
the -v output, because it's different for each file.  It is NOT the
same thing as -I. -I-, contrary to the documentation.

zw


More information about the Gcc-bugs mailing list