在我的应用程序中,我为C/C++/Objective-C使用编译器。是用于模拟器的 Apple LLVM编译器4.1 。
对于模拟器,这是有效的。当我为设备编译相同的代码时,我更改了 C/C++/Objective-C的编译器是 LLVM GCC 4.2。 这次我在stdio.h“sprintf”的类型冲突中遇到错误。
我正在使用Mac OS x 10.7.4
Xcode 4.5(iOS 6)
在(Mac OS x 10.7.4&Xcode 4.2.3(iOS 5))和&(Mac OS x 10.6.8&Xcode 3.2.3(iOS 4))中可以正常工作。
iOS 5和LLVM编译器的iOS 6有什么区别。有人可以帮助我吗?
最佳答案
使用数据类型NSInteger
或NSUInteger
时,在Mac OS X下编译通用应用程序时,我看到此警告:
NSInteger thing = 7;
NSLog(@"Thing is %ld", thing);
这将在64位下运行,但在32位下会发出警告(提示; iOS使用32位体系结构)。
在这种情况下,(丑陋的)解决方案是将
thing
强制为long
:NSLog(@"Thing is %ld", (long)thing);
它将在任何地方工作。
这比以下要好:
#ifdef __x86_64
NSLog(@"Thing is %ld", thing);
#else
NSLog(@"Thing is %d", thing);
#endif
关于compiler-errors - 如何解决错误:Conflicting type for “snprintf” ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13119837/