#include "filename.h" does not mean "include user file"

Eduardo Krell ekrell at ulysses.att.com
Fri Mar 16 14:14:01 AEST 1990


I'm the one who originally implemented the '-I-' flag for gcc-cpp. The
wording I gave FSF is different from the one that appears in the manual
(which is wrong, as you point out).

>    In addition, the '-I-' option inhibits the use of the current directory
>    as the first search directory for '#include "file"'.  Therefore, the
>    current directory is searched only if it is requested explicitly with
>    '-I.'.  Specifying both '-I-' and '-I.' allows you to control precisely
>    which directories are searched before the current one and which are
>    searched after."

What '-I-' does is supress the search in the directory where the including
file is (the file with the #include statement), NOT the current directory.

This is needed because there's no way to override the search in that
directory, which comes first for header files included with "". For
instance, you #include <foo.h>. Inside foo.h there's a #include "bar.h"
which is in the same directory foo.h is.
If you want to use your own bar.h so that it's included by foo.h, there's no
way of doing that since -I. would NOT take precedence over searching
in the same directory where foo.h is. That's the reason why -I-
is needed.
    
Eduardo Krell                   AT&T Bell Laboratories, Murray Hill, NJ

UUCP: {att,decvax,ucbvax}!ulysses!ekrell  Internet: ekrell at ulysses.att.com



More information about the Comp.std.c mailing list