我正在用两个不同的库处理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 (x86)\SiliconSoftware\Runtime5.1\include\msinttypes\stdint.h:91:错误: C2371:'int32_t‘:重新定义;不同的基本类型c:\program (x86)\matlab\r2008a\extern\include\mclmcr.h:216:--参见'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我还是会犯同样的错误。请帮帮忙。
发布于 2014-03-06 16:47:22
H也是一个包含文件的系统。在定义/undef解决方案之前包含它的可能性很大。当您再次尝试包含该文件时,包含守卫会执行他们的工作。您可以使用以下方法检查情况:Displaying the #include hierarchy for a C++ file in Visual Studio
我建议将包含stdint.h的部分移到文件的最顶端,在所有其他内容之前。
要小心,用另一个版本跟踪系统包括stdint.h文件会询问问题。
https://stackoverflow.com/questions/15266053
复制相似问题