2013-03-07 42 views
3

我正在使用两个独立的库的Qt平台。我面临的问题是他的两个库对int32_t有不同的声明。第三方库冲突的定义/ redefinitons

的第一库具有:

#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: error: C2371: 'int32_t' : redefinition; different basic types c:\program files (x86)\matlab\r2008a\extern\include\mclmcr.h:216: see declaration of 'int32_t'

我尝试下面这个职位上计算器:

Typedef redefinition (C2371) for uint32 in two 3rd-party libraries

,我试图实现它在我的代码:

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

我仍然得到同样的错误。请帮忙。

回答

2

stdint.h也是一个系统包含文件。在define/undef解决方法之前包含的机会很好。当你的解决方法试图再次包含该文件时,包容卫士会完成他们的工作。你可以用下面的方法检查一下情况: Displaying the #include hierarchy for a C++ file in Visual Studio

我建议在包含stdint.h的地方将文件的顶部移动到文件的最顶部,然后再包含所有其他文件。

注意,系统包含文件stdint.h与其他版本的问题会产生问题。