Glad: fatal error: typedef redefinition with different types on OSX

Created on 29 Nov 2016  ·  7Comments  ·  Source: Dav1dde/glad

As explained in this issue, it seems OSX already includes GLsizeiptr and a few others. The same problem happens with glad.h as well. The workaround appears to be to use long instead of ptrdiff_t. Here's another example.

bug glad2

Most helpful comment

Trying to look into this issue this weekend, hopefully I can find a way to reproduce it without having access to an OSX instance (I assume just getting the OSX headers is enough).

All 7 comments

Thanks, I will have to look into this and why these types already exist...

Ran into this issue as well, any updates on this?

Trying to look into this issue this weekend, hopefully I can find a way to reproduce it without having access to an OSX instance (I assume just getting the OSX headers is enough).

Cheers :)

The fix looks like this:

#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
typedef long GLintptr;
#else
typedef ptrdiff_t GLintptr;
#endif
#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
typedef long GLsizeiptr;
#else
typedef ptrdiff_t GLsizeiptr;
#endif
typedef int64_t GLint64;
typedef uint64_t GLuint64;
#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
typedef long GLintptrARB;
#else
typedef ptrdiff_t GLintptrARB;
#endif
#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ > 1060)
typedef long GLsizeiptrARB;
#else
typedef ptrdiff_t GLsizeiptrARB;
#endif

OSX Versions > 10.6 (starting with 10.7) only have 64 bit support, unfortunately I cannot test this on an OSX device, please report back if it actually works as intended.

After that I will release a new version and update the online generator.

I put those changes in glad.h. Works for me.

Awesome, thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ButchDean picture ButchDean  ·  4Comments

tysonbrochu picture tysonbrochu  ·  7Comments

Develon5543 picture Develon5543  ·  8Comments

sasmaster picture sasmaster  ·  9Comments

devvoid picture devvoid  ·  8Comments