尝试构建XCode项目以进行发布时出现Typedef重新定义错误

前端之家收集整理的这篇文章主要介绍了尝试构建XCode项目以进行发布时出现Typedef重新定义错误前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我可以在 Xcode(4.2)中构建我的项目以进行调试而不会出现问题,但是当我想构建它以进行发布(构建用于存档)时,我得到错误:“Typedef重新定义具有不同类型(unsigned int vs unsigned long)”.

有问题的代码是:

#ifdef _LZMA_UINT32_IS_ULONG 
typedef long Int32; 
typedef unsigned long UInt32; 
#else 
typedef int Int32; 
typedef unsigned int UInt32; <--error on this line
#endif

你可以看到整个文件
http://read.pudn.com/downloads166/sourcecode/zip/758136/C/Types.h__.htm

以前的定义是在CoreServices框架中的MacTypes.h中.

我有与Debug和Release相同的预处理器宏,我正在使用Apple的LLVM编译器3.0.当我尝试构建用于分析的项目时,会发生同样的错误.

知道为什么会这样吗?

解决方法

在你收到错误的情况下(编译32位时),你已经有了相应的

typedef unsigned int UInt32; <--error on this line

(因此错误)所以你可以删除有问题的行.

显然不是所有的源都包含/导入MacTypes.h,所以要两种方式,用#ifdefs包围违规行,如下所示:

#ifndef __MACTYPES__
typedef unsigned int UInt32;
#endif

不幸的是,这并不完美;你必须确保如果包含MacTypes.h,它会在此之前发生.确保这一点的一种方法是在本地#imports之前进行系统#imports.

猜你在找的Xcode相关文章