SDL OpenGL Typedef Redefinition Error on Mac OS X 10.7

November 7th, 2011

Filed under: Game Development, Mac Development, OpenGL, SDL | 3 comments

If you build a SDL OpenGL application for Mac OS X using SDL 1.2.14 (using the binary installer at the SDL site) and the Mac OS X 10.7 SDK, you can get the following error:

typedef redefinition with different types ('unsigned int' vs 'void *')

The SDL header file SDL_opengl.h and the OpenGL header file glext.h both define a data type GLhandleARB. SDL_opengl.h defines it as an unsigned integer. The Mac OS X 10.7 version of glext.h defines it as a void pointer. Defining GLhandleARB as different data types in different header files causes problems.

The SDL team fixed the problem in their Mercurial repository. The fix is not too difficult to apply. In your SDL_opengl.h file, change the following line of code:

typedef unsigned int GLhandleARB;

To the following:

#if defined(__APPLE__)  
	typedef void *GLhandleARB;
	typedef unsigned int GLhandleARB;

The fix defines GLhandleARB as a void pointer on Mac OS X and an unsigned integer on other operating systems.


3 thoughts on “SDL OpenGL Typedef Redefinition Error on Mac OS X 10.7

  1. Thank you really much! Works fine.

  2. Lukas says:

    Thanks a lot! Solved my problem!

  3. Richard says:

    Excellent thank you for posting.

Leave a Reply

Your email address will not be published. Required fields are marked *