Running old game build in latest Xcode 4 creates conflicts with C function in stdio.h

£可爱£侵袭症+ 提交于 2019-12-11 07:40:09

问题


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.


回答1:


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 as dprintf and Xcode4's stdio.h has definition for dprintf of its own. So, it got conflict, whereas it worked well with previous version of Xcode 3.2.5.

Thanks for everyone who tried to help me out with this issue!!




回答2:


I'm not familiar with Xcode, but my approach to this would be to tell the compiler (gcc in this case) to output the include tree and look there for entries of stdio.h from two separate places. If you post that tree here we may be able to get to the bottom of it - I think that that is done using -verbose and --trace.



来源:https://stackoverflow.com/questions/6854271/running-old-game-build-in-latest-xcode-4-creates-conflicts-with-c-function-in-st

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!