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.
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!!
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
.