Set system search path in Xcode 4

2019-06-25 01:40发布

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?

1条回答
Juvenile、少年°
2楼-- · 2019-06-25 01:48

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.

查看更多
登录 后发表回答