在最新的 Xcode 4 中运行旧游戏版本会与 stdio.h 中的 C 函数发生冲突
我有一个两年前的游戏代码,它完全是用 xcode 中的 cpp (不是 obj C)编写的。现在我必须在最新版本的 Xcode 4 中运行这个游戏。该游戏在 Xcode 3.2.5 上构建得非常好。但是当我用 Xcode4 构建游戏时,它显示以下错误。
GCC 4.2 错误:C 函数声明“int printf(int, const char*, ...)”与 /Developer/Xcode4/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/ 冲突usr/include/stdio.h
红色标记出现在 stdio.h 的第 446 行
谁能告诉我这里发生了什么?提前致谢。任何建议将非常感激。
I have a two year old game code which was completely written in cpp in xcode (not obj C). Now I have to run this game in latest version of Xcode 4. The game builds great with Xcode 3.2.5. But when i built the game with Xcode4, it shows following error.
GCC 4.2 Error: Declaration of C function 'int printf(int, const char*, ...)' conflicts with in /Developer/Xcode4/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.3.sdk/usr/include/stdio.h
The red mark appear in line number 446 in stdio.h
Can anyone please suggest me what is going on here? Thanks in advance. Any suggestions would be very appreciable.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不明白你的代码是用 C++ 编写的(你在问题中提到了 cpp)还是用 C 编写的(这将表明你的问题的标签)。
无论如何,官方
printf()
的原型不包含int
作为第一个参数,因此 Xcode4 有充分的理由抱怨。I don't understand whether your code is written in C++ (you mention cpp in your question) or in C (as would indicate the tag of your question).
Anyway, prototype of official
printf()
doesn't include anint
as first argument, so Xcode4 has valid reasons to complain.当我在一个类型定义文件中评论这一行定义时:
#define dprintf printf
游戏代码已成功构建。问题是
printf
也被定义为dprintf
并且 Xcode4 的 stdio.h 有自己的dprintf
定义。因此,它发生了冲突,而它与以前版本的 Xcode 3.2.5 配合得很好。我猜 Xcode 库文件也有一些变化。感谢所有试图帮助我解决这个问题的人!
When I commented this line definition in one of my type definition file:
#define dprintf printf
The game code built successfully. The problem was that the
printf
was also defined asdprintf
and Xcode4's stdio.h has definition fordprintf
of its own. So, it got conflict, whereas it worked well with previous version of Xcode 3.2.5. I guess there are some changes also in Xcode library files.Thanks for everyone who tried to help me out with this issue!!