2

我正在尝试使用 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
4

1 回答 1

3

You can simply remove these definitions from your code. Both int64_t and u_int64_t are already defined in the iOS SDK headers. (If necessary, add #include <stdint.h>, which is the standard header for exact-width integer types.)

The the error actually occurs in the first part of your code when compiling for 64-bit, because your definitions

typedef long int64_t;
typedef unsigned long u_int64_t;

conflict with the iOS SDK definitions

typedef long long       int64_t;
typedef unsigned long long  u_int64_t;

since long and long long are different types (but of the same size on 64-bit ARM).

于 2013-10-25T05:53:08.857 回答