簡體   English   中英

第三方圖書館定義/重新定義沖突

[英]3rd party libraries conflicting definitions/ redefinitons

我正在使用兩個獨立的庫在Qt平台上工作。 我面臨的問題是他的兩個庫對int32_t有不同的聲明。

第一個圖書館有:

#ifdef _WIN32
#if ULONG_MAX == 0xffffffff 
typedef long int32_t;
#else
typedef int int32_t;
#endif
#endif

第二個圖書館:

typedef signed __int32    int32_t;
typedef unsigned __int32  uint32_t;

我得到的錯誤是:

C:\\ Program Files(x86)\\ SiliconSoftware \\ Runtime5.1 \\ include \\ msinttypes \\ stdint.h:91:錯誤:C2371:'int32_t':redefinition; 不同的基本類型c:\\ program files(x86)\\ matlab \\ r2008a \\ extern \\ include \\ mclmcr.h:216:查看'int32_t'的聲明

我嘗試在stackoverflow上關注這篇文章:

兩個第三方庫中的uint32的typedef重定義(C2371)

我試圖在我的代碼中實現它:

#define int32_t VicTorv3_int32_t
#include"mclmcr.h"
#undef int32_t
#define int32_t Silicon_int32_t
#include "stdint.h"
#undef int32_t

我仍然得到同樣的錯誤。 請幫忙。

stdint.h也是一個系統包含文件。 在define / undef解決方法之前包含它的機會很好。 當您解決方法嘗試再次包含該文件時,包含警衛會完成他們的工作。 您可以使用以下方法檢查情況: 在Visual Studio中顯示C ++文件的#include層次結構

我建議將包含stdint.h的部分移動到文件的最頂部,然后再包含其他部分。

注意,陰影系統包括文件stdint.h與另一個版本請求問題。

暫無
暫無

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

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