GCC doesn't seem to provide a c99 utility, but some vendors provide one based
on gcc. And the GCC behavior can make POSIX conformance difficult to obtain.
Here's the difference.

POSIX.1-2008 says[*]:

  -I  directory
    Change the algorithm for searching for headers whose names are not
    absolute pathnames to look in the directory named by the directory
    pathname before looking in the usual places. Thus, headers whose
    names are enclosed in double-quotes ( "" ) shall be searched for
    first in the directory of the file with the #include line, then in
    directories named in -I options, and last in the usual places. For
    headers whose names are enclosed in angle brackets ( "<>" ), the
    header shall be searched for only in directories named in -I
    options and then in the usual places. Directories named in -I
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    options shall be searched in the order specified. Implementations
    shall support at least ten instances of this option in a single
    c99 command invocation.

[*] http://www.opengroup.org/onlinepubs/9699919799/utilities/c99.html

So, the directories specified by -I should have the precedence over the usual
places. However, this is not the behavior of gcc; from the gcc 4.3.2 man page:

  -I dir
    Add the directory dir to the list of directories to be searched for
    header files.  Directories named by -I are searched before the
    standard system include directories.  If the directory dir is a
    standard system include directory, the option is ignored to ensure
    that the default search order for system directories and the
    special treatment of system headers are not defeated .  If dir
    begins with "=", then the "=" will be replaced by the sysroot
    prefix; see --sysroot and -isysroot.

As you can see, there is a difference for standard system include directories,
for which the option is ignored.

I suggest that GCC adds a new option to switch to the POSIX specifications.
FYI, I've reported the bug against Debian here:

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=533124


-- 
           Summary: Option -I and POSIX conformance (c99 utility)
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: vincent at vinc17 dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40442

Reply via email to