OS X 10.6.8
XCode 3.2.6
一个C ++ Carbon项目,我想包含Cocoa.h只是为了NSLog调试我遇到的一些问题。
我将Cocoa Framework添加到我的项目中,并在预编译的标头中添加#include <Cocoa/Cocoa.h>
,并且从ObjC Runtime内容开始出现9646错误。
我做错了什么?
更新:一些错误:
NSObjCRuntime.h:
/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:60:0
/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:60:
错误:“ @”令牌之前的预期unqualified-id
/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:62:0
/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:62:
错误:“ *”之前的预期构造函数,析构函数或类型转换
代币
/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:63:0
/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:63:
错误:未在此范围内声明“ NSString”
/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:63:0
/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:63:
错误:未在此范围内声明“ aSelectorName”
/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:64:0
/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:64:
错误:未在此范围内声明“ NSString”
/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:64:0
/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:64:
错误:未在此范围内声明“ aClassName”
/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:65:0
/Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:65:
错误:“ *”之前的预期构造函数,析构函数或类型转换
代币
最佳答案
我认为您遇到的问题是某些文件被视为纯C / C ++,并且不应在其中包含Obj C代码。解决方案是更改项目的XCode属性,并说用Obj C或类似的措辞对待C / C ++文件。
关于xcode - 包含Cocoa.h会导致我的项目中发生9646个错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7797680/