Set system search path in Xcode 4

大城市里の小女人 提交于 2019-12-23 12:44:55

问题


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:


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.



来源:https://stackoverflow.com/questions/6322564/set-system-search-path-in-xcode-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!