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

淺唱寂寞╮ 提交于 2019-12-10 19:09:38

问题


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):

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

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?


回答1:


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.



来源:https://stackoverflow.com/questions/12706281/typedef-redefinition-of-uint32-in-mactypes-h-from-definition-in-cfbase-h

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