简体   繁体   English

第三方图书馆定义/重新定义冲突

[英]3rd party libraries conflicting definitions/ redefinitons

I am working on Qt Platform with two separate libraries. 我正在使用两个独立的库在Qt平台上工作。 The Problem that I am facing is that he two libraries have different declaration for int32_t. 我面临的问题是他的两个库对int32_t有不同的声明。

The first library has : 第一个图书馆有:

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

The second Library : 第二个图书馆:

typedef signed __int32    int32_t;
typedef unsigned __int32  uint32_t;

The error that I get is : 我得到的错误是:

C:\\Program Files (x86)\\SiliconSoftware\\Runtime5.1\\include\\msinttypes\\stdint.h:91: error: C2371: 'int32_t' : redefinition; C:\\ Program Files(x86)\\ SiliconSoftware \\ Runtime5.1 \\ include \\ msinttypes \\ stdint.h:91:错误:C2371:'int32_t':redefinition; different basic types c:\\program files (x86)\\matlab\\r2008a\\extern\\include\\mclmcr.h:216: see declaration of 'int32_t' 不同的基本类型c:\\ program files(x86)\\ matlab \\ r2008a \\ extern \\ include \\ mclmcr.h:216:查看'int32_t'的声明

I tried following this post on stackoverflow : 我尝试在stackoverflow上关注这篇文章:

Typedef redefinition (C2371) for uint32 in two 3rd-party libraries 两个第三方库中的uint32的typedef重定义(C2371)

And i tried to implement it in my code : 我试图在我的代码中实现它:

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

I still get the same error. 我仍然得到同样的错误。 Please help. 请帮忙。

stdint.h is also a system include file. stdint.h也是一个系统包含文件。 Chances are good that it gets included before the define/undef workaround. 在define / undef解决方法之前包含它的机会很好。 And when you workaround tries to include the file again, the inclusion guards do their work. 当您解决方法尝试再次包含该文件时,包含警卫会完成他们的工作。 You might check the situation using this: Displaying the #include hierarchy for a C++ file in Visual Studio 您可以使用以下方法检查情况: 在Visual Studio中显示C ++文件的#include层次结构

I suggest moving the part where you include stdint.h to the very top of the file, before ALL other includes. 我建议将包含stdint.h的部分移动到文件的最顶部,然后再包含其他部分。

Be watchful, shadowing the system include file stdint.h with another version asks for problems. 注意,阴影系统包括文件stdint.h与另一个版本请求问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM