我在 MacTypes.h 的以下代码块中的两行中收到 typedef 重新定义错误:
#if __LP64__
typedef unsigned int UInt32;
typedef signed int SInt32;
#else
typedef unsigned long UInt32; // error here
typedef signed long SInt32; // error here
#endif
Clang 错误指向 CFBase.h(在 CoreFoundation.framework 中)中的以下先前定义:
#if !defined(__MACTYPES__)
#if !defined(_OS_OSTYPES_H)
typedef unsigned char Boolean;
typedef unsigned char UInt8;
typedef signed char SInt8;
typedef unsigned short UInt16;
typedef signed short SInt16;
typedef unsigned int UInt32; // previous definition is here
typedef signed int SInt32; // previous definition is here
typedef uint64_t UInt64;
typedef int64_t SInt64;
typedef SInt32 OSStatus;
#endif
...
这很奇怪,因为__LP64__
显然在 Mac 平台上总是正确的,那么为什么要评估 typedef 呢?为什么会出现两个操作系统提供的定义相互矛盾的编译路径?
编辑:这是 Xcode 中错误的屏幕截图。
我已经清空了包含的文件的路径<Carbon/Carbon.h>
因为它包含我的客户的名称(两个错误的文件是相同的)。下面的完整路径名如下(全部包含在 Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks 中):
- Carbon.framework/标头/Carbon.h:20
- CoreServices.framework/标头/CoreServices.h:18
- CoreServices.framework/Frameworks/AE.framework/Headers/AE.h:20
- CoreServices.framework/Frameworks/CarbonCore.framework/Headers/CarbonCore.h:27
- CoreServices.framework/Frameworks/CarbonCore.framework/Headers/MacTypes.h:27
Update:
在我自己的代码中,就在之前#include <Carbon/Carbon.h>
我添加了以下内容:
#if __LP64__
#error Has LP64
#else
#error Doesn't have LP64
#endif
...我收到“没有 LP64”错误,所以这似乎是问题的根源。但是,当我在 Sublime Text 2(使用 SublimeClang)中编译以下内容时...
int main()
{
#if __LP64__
#error Has LP64
#else
#error Doesn't have LP64
#endif
return 0;
}
...我得到“有 LP64”。进行项目文本搜索#define __LP64__
我在我的项目中找不到任何内容,并且在搜索时__LP64__
它只是带来了一堆#if
s and #ifdef
s。有谁知道这个错误可能来自哪里?