在Xcode 4中设置系统搜索路径 [英] Set system search path in Xcode 4

查看:96
本文介绍了在Xcode 4中设置系统搜索路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在C ++命令行项目中设置Xcode 4中的头搜索路径(使用LLVM 2.0 / clang作为编译器),以便我可以通过 #include<包含库头文件; foo>



如果我在构建设置Header Search Paths下包含搜索路径,则会找到标题。不幸的是,我还使用 -Werror 进行编译,并且严格的警告级别和相关标题因此导致编译错误。



<因此,我将通过 -isystem 包含标题搜索路径,以禁用此库标题的警告。但是,我无法在Xcode 4中找到相应的构建设置。Header Search Paths和User Header Search Paths都不起作用。



Xcode不支持 -isystem 标志?

解决方案

正如您所指出的, -isystem gcc 处理系统包含dirs的方式,与 -I 目录, -isystem 将禁止警告以及从系统获得的各种其他行为包括路径。



Xcode可能不会显而易见,但Xcode 4.3 提供的基于llvm的类gcc编译器确实支持此选项,就像gcc一样。这似乎是一个普遍的神话,它不会(毫无疑问,因为它在过去没有),甚至CMake(2.8.7)仍然继续避免使用 -isystem 选项。



对于那些手工制作Xcode项目的人来说,你的标题搜索路径(而不是用户标题搜索路径)正如你所提到的,项目设置也会起作用,如果你不使用像CMake这样的东西来构建你的Xcode项目,它可能会更容易。


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?

解决方案

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.

这篇关于在Xcode 4中设置系统搜索路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆