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

In my application, I use Box2D and Spidermonkey . Both libraries define the uint32 type, which obviously gives me a compiler error when used as in a single compilation unit.

b2settings.h (Box2D): typedef unsigned int uint32;

jsotypes.h (Spidermonkey): typedef unsigned long uint32;

Is there a way to resolve this collision without changing the headers of third-party libraries?

I am grateful for every hint!

+3
source share
1 answer

You can do this hack:

#define uint32 Box2D_uint32
#include "Box2D.h"
#undef uint32
#define uint32 Spider_uint32
#include "Spidermonkey.h"
#undef uint32

typedef , ODR, . (struct or inline function), uint32, ODR. , , , , .

- , , , .

+3

Source: https://habr.com/ru/post/1779742/


All Articles