4

I’m trying to set the header search path in Xcode 4 (using LLVM 2.0 / clang as compiler) in a C++ command line project so that I can include a library header file via #include <foo>.

If I include the search path under the build setting “Header Search Paths” then the header is found. Unfortunately, I also compile with -Werror and a strict warning level and the header in question thus causes a compile error.

I would therefore include the header search path via -isystem in order to disable warnings for this library header. However, I’m unable to find the corresponding build setting in Xcode 4. Neither “Header Search Paths” nor “User Header Search Paths” works.

Does Xcode not support the -isystem flag?

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
  • (This is *not* a duplicate of either [q/5269029](http://stackoverflow.com/q/5269029/1968) or [q/3428216](http://stackoverflow.com/q/3428216/1968)) – Konrad Rudolph Jun 12 '11 at 14:47
  • What about manually passing flags to the compiler? I don't use Xcode, so I don't know if that's an option. – Xeo Jun 12 '11 at 15:48
  • @Xeo You can specify manual options but somehow this didn’t work for me so I suspect that Xcode forbids passing manual options that might conflict with automatic options. That said, I’m unsure about the manual options format; I’ve tried several things that didn’t work. – Konrad Rudolph Jun 12 '11 at 16:52

1 Answers1

3

As you have pointed out, -isystem is the way gcc handles system include dirs, and unlike -I directories, the -isystem ones will have warnings suppressed and the various other behaviors you get from system include paths.

Xcode may not make it obvious, but the llvm-based gcc-like compiler provided with Xcode 4.3 does support this option just like gcc. It seems to be a common myth that it doesn't (no doubt because it didn't in the past), and even CMake (2.8.7) still continues to avoid using the -isystem option with Xcode.

For those making Xcode projects by hand, the "Header Search Paths" (as opposed to "User Header Search Paths") in your project settings will also work, as you've mentioned, and is probably easier if you don't use something like CMake to build your Xcode project.

drfrogsplat
  • 2,577
  • 3
  • 19
  • 28
  • I added some third party headers to `Header Search Paths` - but yet Xcode pass them with `-I`. – thomthom Feb 09 '16 at 20:06
  • The first comment to this answer solved my issue - basically overriding the C++ Flags to force `-isystem`: http://stackoverflow.com/q/22020442/486990 – thomthom Feb 09 '16 at 20:20