home | list info | list archive | date index | thread index

[OCLUG-Tech] looking for clarification of obsolescence of "-I-" option with gcc

  • Subject: [OCLUG-Tech] looking for clarification of obsolescence of "-I-" option with gcc
  • From: "Robert P. J. Day" <rpjday [ at ] crashcourse [ dot ] ca>
  • Date: Tue, 29 Mar 2016 18:17:20 -0400 (EDT)
  ok, let's see if i can keep this short; colleague asks me how to get
around recent dropping of "-I-" option from gcc, whose effect was to
mess with the header file search path as follows:

-I- Split the include path.  Any directories specified with -I options before -I-
    are searched only for headers requested with "#include "file""; they are not
    searched for "#include <file>".  If additional directories are specified with
    -I options after the -I-, those directories are searched for all #include
    directives.

    In addition, -I- inhibits the use of the directory of the current file
    directory as the first search directory for "#include "file"".  This option
    has been deprecated.

  apparently, the code base in question relied *heavily* on the use of
"-I-" to support the ability to include a header file thusly:

  #include "rday.h"

but to *not* look in the current directory immediately; rather, even
though the filename was inside quotes, the requirement was to start
the search all over from the beginning in order to pick up possible
*override* header files (i'm going to guess precompiled header files
that now existed earlier in the search path, but that's just a guess).

  in any event, gcc 5.2.0 has dropped the "-I-", at which point this
sizable code base no longer builds without the effect of that option.
so what to do?

  my initial reaction was ... yuck. but once i got past that, well,
what *is* the solution? i can see that the gcc folks now recommend
using "-iquote", but here's a bug report making it clear that quite a
few people are miffed by this change:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=19541

  anyone have any comments on this? it seems pretty clear the value of
this feature was to allow precompiled header files to override ones in
the current directory, but it occurs to me that it's not necessary to
restart the search at the *beginning* of the search path, but simply
to allow the definition of *some* set of high-priority directories
that will be searched first before returning to the current directory.

  thoughts? i can see the options "-isystem" and "-isysroot", so i'm
wondering if that's the solution. if there is another solution, feel
free to let me know.

rday

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================