Fixed bug 1983 - SDL_thread.h broken under MinGW crosscompiling environment
authorSam Lantinga <slouken@libsdl.org>
Sat, 27 Jul 2013 03:44:03 -0700
changeset 75281890a896802f
parent 7527 7e254bcd3b9d
child 7529 3f571ec09593
Fixed bug 1983 - SDL_thread.h broken under MinGW crosscompiling environment

q66

after updating SDL2 to the latest RC I'm unable to build my game engine under mingw crosscompiling environment for Windows (32bit, hosted on freebsd 64bit).

The error is in SDL_thread.h with messages like this: http://codepad.org/jEQXd3Yq

The problem is, while _beginthreadex return type is correctly mapped to uintptr_t (as specified by Microsoft), the return type under mingw is unsigned long int (same size, different signature), resulting in the error above.

The reason it didn't error before is this: http://codepad.org/8FAbKAxz

You can see the _beginthreadex case is only used without HAVE_LIBC defined; at one point though, SDL_config_windows.h was changed like this:

-/* Enabled for SDL 1.2 (binary compatibility) */
-#define HAVE_LIBC 1
+/* This is disabled by default to avoid C runtime dependencies and manifest requirements */

resulting in these errors.
include/SDL_thread.h
     1.1 --- a/include/SDL_thread.h	Sat Jul 27 03:22:37 2013 -0700
     1.2 +++ b/include/SDL_thread.h	Sat Jul 27 03:44:03 2013 -0700
     1.3 @@ -109,7 +109,7 @@
     1.4  /**
     1.5   *  Create a thread.
     1.6   */
     1.7 -#define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, _beginthreadex, _endthreadex)
     1.8 +#define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, (pfnSDL_CurrentBeginThread)_beginthreadex, (pfnSDL_CurrentEndThread)_endthreadex)
     1.9  
    1.10  #else
    1.11