c++ - Xcode #Include 从3.2.6更新到4.5.1后的文件问题

标签 c++ xcode include xcode4.5

自从将 C++ 项目从 Xcode 3.2.6 升级到 Xcode 4.5.1 以来,我遇到了最奇怪的 #include 文件问题:无法找到我的静态链接库之一的 #include 头文件。对于整个项目,我没有其他 undefined symbol 错误。

#include 位于前缀 header “MacClient_Prefix.pch”中(我没有预编译 header ):

#include "Framework/Base/BaseEnvironment.h"

此头文件 (BaseEnvironment.h) 位于与静态链接库相关的完全不同的文件夹层次结构中。

错误:

/Users/StephenDev/Documents/dev/WordMenu/Projects/MacClient/Xcode/WordMenuBaseEnv.h
/Users/StephenDev/Documents/dev/WordMenu/Projects/MacClient/Xcode/WordMenuBaseEnv.h:26:10: 'Framework/Base/BaseEnvironment.h' file not found
/Users/StephenDev/Documents/dev/WordMenu/Projects/MacClient/Xcode/<built-in>:148:2: In file included from <built-in>:148:
/Users/StephenDev/Documents/dev/WordMenu/Projects/MacClient/Xcode/<command line>:4:10: In file included from <command line>:4:
/Users/StephenDev/Documents/dev/WordMenu/Projects/MacClient/Xcode/MacClient_Prefix.pch:9:10: In file included from
     /Users/StephenDev/Documents/dev/WordMenu/Projects/MacClient/Xcode/MacClient_Prefix.pch:9:

我相当确定为项目正确设置了用户头文件路径。

奇怪的是,如果我将#include 注释掉,那么我会得到数百个实际错误,因为其余代码中缺少符号。很明显,当使用前缀 header 编译项目文件时,就会找到该文件。

我什至尝试在 #include 中明确指定头文件的完整路径,但这会破坏项目构建其余部分的包含。

我在构建选项中的包含路径是项目相关的,我认为这可能与这个问题有关。该问题是否与派生数据或中间体的包含路径有关?

包含在有错误的“主”项目中的静态链接库的构建项目确实将头文件定义为“公共(public)”。但是,主项目的干净构建/重建似乎(目前)不会重新构建静态链接库。

最佳答案

What's odd is that if I COMMENT OUT the #include, then I get hundreds of actual errors for missing symbols from the rest of the code. So clearly, the file IS being found when the prefix header is used for compiling the project files.

#include 错误是致命的,因此编译器不会继续显示因缺少#include 而导致的所有错误。

#include <foo>
There's no way this is legal C++...

结果:

main.cpp:1:10: fatal error: 'foo' file not found
#include <foo>
         ^
1 error generated.

没有其他错误的事实并不意味着第二行被解释为有效的 C++ 代码。

关于c++ - Xcode #Include 从3.2.6更新到4.5.1后的文件问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15666633/

相关文章:

c++ - 为什么输出的每一行之前都有不必要的空格?

c++ - Having trouble importing function from C++ dll 错误 LNK 2019

c++ - 通过引用传递带有枚举类的枚举

c++ - #包括任何地方

Erlang:从控制台使用包含?

c++ - C/C++中int的字符串化

xcode - target 指定产品类型 'com.apple.product-type.app-extension' ,但是 'iphoneos' 平台没有这样的产品类型

ios - 如果标签在 Xcode (Swift) 中被截断,如何更改 UILabel 大小

ios - undefined symbol Swift.UnsafeMutableBufferPointer

php - 将 PHP 结果放入 HTML 页面