typedef重定义错误Xcode 5,iOS7和64bit vs 32bit

时间:2013-10-25 04:48:31

标签: ios c xcode

我正在尝试使用xcode 5在64位ios 7中构建一个32位的现有项目。在使用架构arm64构建时,会发生typedef重定义错误。 Xcode 5 llvm编译器显示redine错误。在下面我主要发布我得到错误的示例代码。

#if defined (__LP64__)

typedef long int64_t;

typedef unsigned long u_int64_t;
#else

typedef long long          int64_t;
 //shows redefine error int64_t long vs long long

typedef unsigned long long u_int64_t; 
//shows redefine error u_int64_t unsigned long vs unsigned long long 
#endif

1 个答案:

答案 0 :(得分:3)

您只需从代码中删除这些定义即可。 iOS SDK标头中已经定义了int64_tu_int64_t。 (如有必要,添加#include <stdint.h>,这是标准标题 精确宽度整数类型。)

错误实际发生在 编译64位时代码的第一部分,因为你的定义

typedef long int64_t;
typedef unsigned long u_int64_t;

与iOS SDK定义冲突

typedef long long       int64_t;
typedef unsigned long long  u_int64_t;

因为longlong long是不同的类型(但64位ARM上的 相同大小 )。