簡體   English   中英

根據CFBase.h中的定義,在MacTypes.h中對typentf重新定義UInt32

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

我在MacTypes.h的兩行中得到了typedef重定義錯誤,在下面的代碼塊中:

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

Clang錯誤指向CFBase.h中的以下先前定義(在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
...

這很奇怪,因為__LP64__在Mac平台上顯然總是如此,那么為什么typedef甚至被評估? 為什么有一個編譯路徑,其中兩個OS提供的定義相互矛盾?

編輯:這是Xcode中的錯誤的屏幕截圖。

Xcode錯誤輸出

我已經刪除了包含<Carbon/Carbon.h>的文件的路徑,因為它包含我的客戶端的名稱(兩個錯誤的文件相同)。 下面的完整路徑名如下(全部包含在Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks中):

  • Carbon.framework /頭/ Carbon.h:20
  • CoreServices.framework /頭/ CoreServices.h:18
  • CoreServices.framework /框架/ AE.framework /頭/ AE.h:20
  • CoreServices.framework /框架/ CarbonCore.framework /頭/ CarbonCore.h:27
  • CoreServices.framework /框架/ CarbonCore.framework /頭/ MacTypes.h:27

更新:

在我自己的代碼中,就在#include <Carbon/Carbon.h>我添加了以下內容:

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

...而且我得到'沒有LP64'錯誤,所以這似乎是問題的根源。 但是,當我在Sublime Text 2(使用SublimeClang)中編譯以下內容時......

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

......我得到“有LP64”。 #define __LP64__進行項目文本搜索我在項目中找不到任何內容,並且在搜索__LP64__ ,只需要加載#if s和#ifdef s。 有誰知道這個錯誤可能來自哪里?

最后它發現這個問題是由於多次安裝Xcode:我最近安裝了Xcode 4.4(來自App Store),我仍然在某處安裝了Xcode 3。 我通過運行uninstall-devtools Xcode 3的uninstall-devtools以及Library和Developer文件夾中的所有各種路徑解決了這個問題。 我不確定為什么沖突的Xcode安裝會導致這樣的問題,但刪除Xcode 3解決了它。 我希望這可以幫助任何有這樣問題的人 - 這肯定不是我預期的問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM