compiler-errors - 如何解决错误:Conflicting type for “snprintf”

标签 compiler-errors osx-lion xcode4.5 llvm-gcc llvm-clang

在我的应用程序中,我为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有什么区别。有人可以帮助我吗?

最佳答案

使用数据类型NSIntegerNSUInteger时,在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/

相关文章:

c - 无法在 C 中对 pow() 使用模

macos - 在 OS X 上的 QT4 中启用 OpenGL 核心配置文件

ios - 无线开发 iPad

cocoa - 滚动 NSTextView 使滚动条处于错误位置

c++ - 使用 Xcode 4.5 调试 c++ 时,单步执行代码会停止在 STL 代码上

cordova - 新的 ios6 架构错误 : file is universal (3 slices) but does not contain a(n) arm7vs slice

c++ - "error: invalid conversion from ' int' 到 'int (*)[8]' [-fpermissive] 的含义是什么?

linux - 使用 "gcc $(pkg-config --cflags --libs glib-2.0) context.c"编译时出错 -> <galloca.h> 未找到

gcc - 无法接受正确的GNU编译器

ios - Xcode 4.5 - CopyPNGFile 仍然存在。需要新的想法