2

I have seen this question already.
Many compilers and compiler toolchains support the -I <dir> and -isystem <dir> command line arguments. I do know that they add directories to the search path and system search path respectively and that system directories get searched last and that -isystem helps you override default system libraries.
I also know that they get special treatment by GCC 'to fix buggy system headers' but what specifically does GCC do in this 'special treatment'?
Also, It is unclear to me if the compiler only looks in the specified directory and no deeper, or if these directories are searched recursively to some extent.

If I need to access resources in /path/to/lib and path/to/lib/aBitFurther do I only need -I /path/to/lib?

too honest for this site
  • 12,050
  • 4
  • 30
  • 52
Culex
  • 300
  • 1
  • 9
  • Another SO question is no subsititute for reading the documentation. – underscore_d Jul 20 '17 at 14:39
  • 2
    no it's no recursive search. You have to pass all dirs. – Jean-François Fabre Jul 20 '17 at 14:40
  • I've been through clang and GCC documentation. for -I and -isystem they just say 'the paths are added to the search' but don't describe _how_ the paths are searched. My experience points to that the search has no depth, but I've found there are exceptions all over the place with lower level things so it's best to double check with those who have experience. As for the systemdir special case handling, it is not well documented in the GCC documentation, and I am not in direct need of knowing. just curious. Seeing if someone else has a general idea or knows where to look for meaningful info – Culex Jul 20 '17 at 16:00

1 Answers1

1

The main differences is that GCC suppresses warnings in system headers. In some cases, this enables those headers to use certain non-standard GNU extensions.

The treatment for buggy system headers you mention is an overlay directory tree with header files preprocessed using the fixincludes tool, but that's not something you'll see on GNU/Linux systems because it is extremely messy and causes lots of problems (such as hiding subsequent updates of the official system headers). I hope it's of historic interest only by this point (although GCC still prepares these headers during its build process).

Florian Weimer
  • 32,022
  • 3
  • 48
  • 92