xcodetypedefredefinitionllvm-3.0

Typedef redefinition error when trying to build XCode project for release


I can build my project in Xcode(4.2) for debugging without issues, but when I want to build it for release (build for archiving) I get error:"Typedef redefinition with different types (unsigned int vs unsigned long)".

Problematic code is:

#ifdef _LZMA_UINT32_IS_ULONG 
typedef long Int32; 
typedef unsigned long UInt32; 
#else 
typedef int Int32; 
typedef unsigned int UInt32; <--error on this line
#endif

You can see whole file on: http://read.pudn.com/downloads166/sourcecode/zip/758136/C/Types.h__.htm

Previous definition is in MacTypes.h from CoreServices framework.

I have the same preprocessor macros for Debug and Release, and I am using Apple's LLVM compiler 3.0. Same error happens when I try to build project for analyzing.

Any idea why this is happening?


Solution

  • In the case where you're getting the error (when compiling 32 bit) you already have the equivalent of

    typedef unsigned int UInt32; <--error on this line
    

    (hence the error) So you can delete the offending line.

    Apparently not all of your source includes / imports MacTypes.h, so to have it both ways, surround the offending line with #ifdefs like so:

    #ifndef __MACTYPES__
    typedef unsigned int UInt32;
    #endif
    

    Unfortunately this is not perfect; you need to be sure that if MacTypes.h is included, it happens before this. One way to ensure that is to do your system #imports before your local #imports.