24

From this link: http://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html

If a standard system include directory, or a directory specified with -isystem, is also specified with -I, the -I option will be ignored. The directory will still be searched but as a system directory at its normal position in the system include chain.

What is the way to run this?

[14:45:37 Wed Apr 27] ~/junkPrograms/src  $gcc hello.c -isystem -I ../include/
../include/: file not recognized: Is a directory
collect2: ld returned 1 exit status
[14:45:42 Wed Apr 27] ~/junkPrograms/src  $gcc hello.c -I isystem ../include/
../include/: file not recognized: Is a directory
collect2: ld returned 1 exit status
[14:45:57 Wed Apr 27] ~/junkPrograms/src  $

and does this mean that if -isystem is attached, the dir will be given the precedence of a normal system dir?

Aquarius_Girl
  • 21,790
  • 65
  • 230
  • 411

1 Answers1

38

The documentation says:

-isystem dir

Search dir for header files, after all directories specified by -I but before the standard system directories. Mark it as a system directory, so that it gets the same special treatment as is applied to the standard system directories. If dir begins with =, then the = will be replaced by the sysroot prefix; see --sysroot and -isysroot.

So you're using it wrong. You need to specify a directory for the -isystem option itself, it doesn't work like a "modifier" of the -I option like you seem to be trying.

I believe your command should be:

$ gcc -isystem ../include hello.c

System headers get special treatment w.r.t. warnings (since they are read only, and some cannot be written in strictly conforming code)

Community
  • 1
  • 1
unwind
  • 391,730
  • 64
  • 469
  • 606
  • So, how it should be? He has an example. Can you write fixed command? – BЈовић Jun 09 '16 at 17:18
  • what is the "special treatment" as is applied to the standard system directories? – user3667089 Dec 13 '16 at 17:52
  • Do you know if it matters if -isystem is before/after -I arguments? – felipeduque Jul 27 '18 at 12:45
  • I added a link to the system headers docs (awaiting moderation): https://gcc.gnu.org/onlinedocs/cpp/System-Headers.html – qneill Oct 19 '18 at 15:27
  • 1
    The link in the answer is not pointing to the intended content anymore. https://gcc.gnu.org/onlinedocs/gcc/Directory-Options.html might be a better read these days. –  Mar 24 '19 at 12:10