3

I am working on Qt Platform with two separate libraries. The Problem that I am facing is that he two libraries have different declaration for 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; different basic types c:\program files (x86)\matlab\r2008a\extern\include\mclmcr.h:216: see declaration of 'int32_t'

I tried following this post on stackoverflow :

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

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.

Community
  • 1
  • 1
Alok
  • 163
  • 1
  • 14

1 Answers1

2

stdint.h is also a system include file. Chances are good that it gets included before the define/undef workaround. 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

I suggest moving the part where you include stdint.h to the very top of the file, before ALL other includes.

Be watchful, shadowing the system include file stdint.h with another version asks for problems.

Community
  • 1
  • 1
Matthias
  • 1,296
  • 8
  • 17