CLANG提出错误抱怨有缺陷的头文件UILocalizedIndexedCollat​​ion.h

Boo*_*oon 4 iphone clang

使用CLANG构建代码时遇到此错误:

In file included from /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:31,
                 from /Users/waspfish/Documents/NanaimoStudio/Projects/iPhoneMonk/Projects/IdeaOrganizer/IdeaOrganizer_Prefix.pch:13,
                 from :1:
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UILocalizedIndexedCollation.h:13: error: syntax error before ‘AT_NAME’ token
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UILocalizedIndexedCollation.h:21: error: syntax error before ‘}’ token
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UILocalizedIndexedCollation.h:23: fatal error: method definition not in @implementation context
compilation terminated.
{standard input}:32:FATAL:.abort  detected.  Assembly stopping.

我最终不得不从UIKit.h中排除UILocalizedIndexedCollat​​ion.h并且一切都很好.知道什么可能导致问题吗?我无法想象Apple正在发送有缺陷的头文件.

小智 7

问题来自SDK 3.0,它现在使用gcc 4.2但是scan-build仍然使用/ usr/bin/gcc.所以你需要告诉scan-build使用/usr/bin/gcc-4.2.

scan-build --use-cc=/usr/bin/gcc-4.2 xcodebuild -configuration Debug
Run Code Online (Sandbox Code Playgroud)

瞧瞧!