【问题标题】:3rd party libraries conflicting definitions/ redefinitons3rd 方库冲突的定义/重新定义
【发布时间】:2013-03-07 08:07:08
【问题描述】:

我正在使用两个独立的库在 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':重新定义;不同的基本类型 c:\program files (x86)\matlab\r2008a\extern\include\mclmcr.h:216:参见“int32_t”的声明

我尝试在 stackoverflow 上关注这篇文章:

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

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

【问题讨论】:

    标签: c++ c qt typedef c-preprocessor


    【解决方案1】:

    stdint.h 也是一个系统包含文件。它很有可能在定义/取消定义解决方法之前被包含在内。并且当您尝试再次包含该文件时,包含保护会执行其工作。您可以使用以下方法检查情况: Displaying the #include hierarchy for a C++ file in Visual Studio

    我建议将包含 stdint.h 的部分移到文件的最顶部,在所有其他包含之前。

    请注意,用另一个版本隐藏系统包含文件 stdint.h 会导致问题。

    【讨论】:

      猜你喜欢
      • 2011-05-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-02
      • 1970-01-01
      • 2015-03-27
      • 2016-05-22
      相关资源
      最近更新 更多