Typedef redefinition of UInt32 in MacTypes.h, from definition in CFBase.h

I’m getting a typedef redefinition error on two lines in MacTypes.h, in the following chunk of code:

#if __LP64__
typedef unsigned int                    UInt32;
typedef signed int                      SInt32;
#else
typedef unsigned long                   UInt32; // error here
typedef signed long                     SInt32; // error here
#endif

The Clang error points to the following previous definition, in CFBase.h (in CoreFoundation.framework):

  • C++11 for xCode errors
  • send push notification to Iphone from asp.net C#
  • Calculating convexityDefects using OpenCV 2.4 in c++
  • How to read a single line of numbers into different variables?
  • Using popen() to open a program in command line?
  • Open another app and pass in url
  • #if !defined(__MACTYPES__)
    #if !defined(_OS_OSTYPES_H)
    typedef unsigned char           Boolean;
    typedef unsigned char           UInt8;
    typedef signed char             SInt8;
    typedef unsigned short          UInt16;
    typedef signed short            SInt16;
    typedef unsigned int            UInt32; // previous definition is here
    typedef signed int              SInt32; // previous definition is here
    typedef uint64_t            UInt64;
    typedef int64_t         SInt64;
    typedef SInt32                  OSStatus;
    #endif
    ...
    

    This is very strange, since __LP64__ is apparently always true on the Mac platform, so why is that typedef even being evaluated? And why is there a path of compilation in which two OS-provided definitions are contradicting each other?

    EDIT: Here is a screenshot of the errors in Xcode.

    Xcode error output

    I’ve blanked out the path of the file that includes <Carbon/Carbon.h> since it contains the name of my client (the file is the same for both errors). The full path names below that are as follows (all contained within Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks):

    • Carbon.framework/Headers/Carbon.h:20
    • CoreServices.framework/Headers/CoreServices.h:18
    • CoreServices.framework/Frameworks/AE.framework/Headers/AE.h:20
    • CoreServices.framework/Frameworks/CarbonCore.framework/Headers/CarbonCore.h:27
    • CoreServices.framework/Frameworks/CarbonCore.framework/Headers/MacTypes.h:27

    Update:

    In my own code, just before #include <Carbon/Carbon.h> I’ve added the following:

    #if __LP64__
    #error Has LP64
    #else
    #error Doesn't have LP64
    #endif
    

    …and I’m getting the ‘Doesn’t have LP64’ error, so this seems to be the root of the problem. However, when I compile the following in Sublime Text 2 (with SublimeClang)…

    int main()
    {
        #if __LP64__
        #error Has LP64
        #else
        #error Doesn't have LP64
        #endif
        return 0;
    }
    

    …I get “Has LP64”. Doing a project text search for #define __LP64__ I can’t find anything in my project, and when searching for __LP64__ it just comes up with a load of #ifs and #ifdefs. Does anyone know where this error could have come from?

    Solutions Collect From Internet About “Typedef redefinition of UInt32 in MacTypes.h, from definition in CFBase.h”

    In the end it turned out this problem was due to multiple installs of Xcode: I had recently installed Xcode 4.4 (from the App Store) and I still had an install of Xcode 3 somewhere. I solved this by running uninstall-devtools which removed Xcode 3, along with all its various paths in the Library and Developer folders. I’m not sure why conflicting installs of Xcode would cause a problem like this, but removing Xcode 3 solved it. I hope this helps anyone who has a problem like this – it’s certainly not what I expected the problem to be.