Fixed building using MinGW Our SDL_windows.h needed to be included before anything else so UNICODE is defined.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395
diff --git a/src/SDL.c b/src/SDL.c
index b111115..619a0c1 100644
--- a/src/SDL.c
+++ b/src/SDL.c
@@ -20,6 +20,10 @@
*/
#include "SDL_config.h"
+#if defined(__WIN32__)
+#include "core/windows/SDL_windows.h"
+#endif
+
/* Initialization code for SDL */
#include "SDL.h"
@@ -443,7 +447,6 @@ SDL_GetPlatform()
#if !defined(HAVE_LIBC) || (defined(__WATCOMC__) && defined(BUILD_DLL))
/* Need to include DllMain() on Watcom C for some reason.. */
-#include "core/windows/SDL_windows.h"
BOOL APIENTRY
_DllMainCRTStartup(HANDLE hModule,
diff --git a/src/SDL_assert.c b/src/SDL_assert.c
index a4cf643..41c6ad6 100644
--- a/src/SDL_assert.c
+++ b/src/SDL_assert.c
@@ -20,6 +20,10 @@
*/
#include "SDL_config.h"
+#if defined(__WIN32__)
+#include "core/windows/SDL_windows.h"
+#endif
+
#include "SDL.h"
#include "SDL_atomic.h"
#include "SDL_messagebox.h"
@@ -29,8 +33,6 @@
#include "video/SDL_sysvideo.h"
#ifdef __WIN32__
-#include "core/windows/SDL_windows.h"
-
#ifndef WS_OVERLAPPEDWINDOW
#define WS_OVERLAPPEDWINDOW 0
#endif
diff --git a/src/SDL_log.c b/src/SDL_log.c
index 802a6f2..18611ca 100644
--- a/src/SDL_log.c
+++ b/src/SDL_log.c
@@ -20,6 +20,10 @@
*/
#include "SDL_config.h"
+#if defined(__WIN32__)
+#include "core/windows/SDL_windows.h"
+#endif
+
/* Simple log messages in SDL */
#include "SDL_log.h"
@@ -28,9 +32,7 @@
#include <stdio.h>
#endif
-#if defined(__WIN32__)
-#include "core/windows/SDL_windows.h"
-#elif defined(__ANDROID__)
+#if defined(__ANDROID__)
#include <android/log.h>
#endif
diff --git a/src/atomic/SDL_spinlock.c b/src/atomic/SDL_spinlock.c
index f3aeea0..0826a3f 100644
--- a/src/atomic/SDL_spinlock.c
+++ b/src/atomic/SDL_spinlock.c
@@ -20,14 +20,14 @@
*/
#include "SDL_config.h"
+#ifdef __WIN32__
+#include "../core/windows/SDL_windows.h"
+#endif
+
#include "SDL_atomic.h"
#include "SDL_mutex.h"
#include "SDL_timer.h"
-/* Don't do the check for Visual Studio 2005, it's safe here */
-#ifdef __WIN32__
-#include "../core/windows/SDL_windows.h"
-#endif
/* This function is where all the magic happens... */
SDL_bool
diff --git a/src/core/windows/SDL_windows.c b/src/core/windows/SDL_windows.c
index e69d257..6ac86a6 100644
--- a/src/core/windows/SDL_windows.c
+++ b/src/core/windows/SDL_windows.c
@@ -22,8 +22,8 @@
#ifdef __WIN32__
-#include "SDL_error.h"
#include "SDL_windows.h"
+#include "SDL_error.h"
#include "SDL_assert.h"
#include <objbase.h> /* for CoInitialize/CoUninitialize */
diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c
index 5e048f9..2b81f91 100644
--- a/src/cpuinfo/SDL_cpuinfo.c
+++ b/src/cpuinfo/SDL_cpuinfo.c
@@ -20,6 +20,10 @@
*/
#include "SDL_config.h"
+#if defined(__WIN32__)
+#include "../core/windows/SDL_windows.h"
+#endif
+
/* CPU feature detection for SDL */
#include "SDL_cpuinfo.h"
@@ -41,9 +45,6 @@
#include <signal.h>
#include <setjmp.h>
#endif
-#ifdef __WIN32__
-#include "../core/windows/SDL_windows.h"
-#endif
#define CPU_HAS_RDTSC 0x00000001
#define CPU_HAS_ALTIVEC 0x00000002
diff --git a/src/file/SDL_rwops.c b/src/file/SDL_rwops.c
index dc89e22..d71dbfd 100644
--- a/src/file/SDL_rwops.c
+++ b/src/file/SDL_rwops.c
@@ -22,6 +22,11 @@
#define _LARGEFILE64_SOURCE
#include "SDL_config.h"
+#if defined(__WIN32__)
+#include "../core/windows/SDL_windows.h"
+#endif
+
+
/* This file provides a general interface for SDL to read and write
data sources. It can easily be extended to files, memory, etc.
*/
@@ -42,8 +47,6 @@
/* Functions to read/write Win32 API file pointers */
-#include "../core/windows/SDL_windows.h"
-
#ifndef INVALID_SET_FILE_POINTER
#define INVALID_SET_FILE_POINTER 0xFFFFFFFF
#endif
diff --git a/src/joystick/windows/SDL_mmjoystick.c b/src/joystick/windows/SDL_mmjoystick.c
index f236dff..e012d44 100644
--- a/src/joystick/windows/SDL_mmjoystick.c
+++ b/src/joystick/windows/SDL_mmjoystick.c
@@ -33,6 +33,11 @@
#include "../SDL_sysjoystick.h"
#include "../SDL_joystick_c.h"
+#ifdef REGSTR_VAL_JOYOEMNAME
+#undef REGSTR_VAL_JOYOEMNAME
+#endif
+#define REGSTR_VAL_JOYOEMNAME "OEMName"
+
#define MAX_JOYSTICKS 16
#define MAX_AXES 6 /* each joystick can have up to 6 axes */
#define MAX_BUTTONS 32 /* and 32 buttons */
@@ -45,7 +50,7 @@
/* array to hold joystick ID values */
static UINT SYS_JoystickID[MAX_JOYSTICKS];
-static JOYCAPS SYS_Joystick[MAX_JOYSTICKS];
+static JOYCAPSA SYS_Joystick[MAX_JOYSTICKS];
static char *SYS_JoystickName[MAX_JOYSTICKS];
/* The private structure used to keep track of a joystick */
@@ -148,7 +153,7 @@ SDL_SYS_JoystickInit(void)
int i;
int maxdevs;
JOYINFOEX joyinfo;
- JOYCAPS joycaps;
+ JOYCAPSA joycaps;
MMRESULT result;
/* Reset the joystick ID & name mapping tables */
@@ -166,7 +171,7 @@ SDL_SYS_JoystickInit(void)
joyinfo.dwFlags = JOY_RETURNALL;
result = joyGetPosEx(i, &joyinfo);
if (result == JOYERR_NOERROR) {
- result = joyGetDevCaps(i, &joycaps, sizeof(joycaps));
+ result = joyGetDevCapsA(i, &joycaps, sizeof(joycaps));
if (result == JOYERR_NOERROR) {
SYS_JoystickID[SDL_SYS_numjoysticks] = i;
SYS_Joystick[SDL_SYS_numjoysticks] = joycaps;
diff --git a/src/main/windows/SDL_windows_main.c b/src/main/windows/SDL_windows_main.c
index 519ce14..4e8e3f2 100644
--- a/src/main/windows/SDL_windows_main.c
+++ b/src/main/windows/SDL_windows_main.c
@@ -7,12 +7,12 @@
#ifdef __WIN32__
+/* Include this so we define UNICODE properly */
+#include "../../core/windows/SDL_windows.h"
+
#include <stdio.h>
#include <stdlib.h>
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-
/* Include the SDL main definition header */
#include "SDL.h"
#include "SDL_main.h"
diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c
index 33665e3..67cddb3 100644
--- a/src/render/direct3d/SDL_render_d3d.c
+++ b/src/render/direct3d/SDL_render_d3d.c
@@ -22,7 +22,6 @@
#if SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED
-
#include "../../core/windows/SDL_windows.h"
#include "SDL_hints.h"
diff --git a/src/render/software/SDL_rotate.c b/src/render/software/SDL_rotate.c
index 628c8d5..44678cb 100644
--- a/src/render/software/SDL_rotate.c
+++ b/src/render/software/SDL_rotate.c
@@ -30,8 +30,8 @@ Andreas Schiffler -- aschiffler at ferzkopp dot net
*/
#include "SDL_config.h"
-#ifdef WIN32
-#include <windows.h>
+#if defined(__WIN32__)
+#include "../../core/windows/SDL_windows.h"
#endif
#include <stdlib.h>
diff --git a/src/stdlib/SDL_getenv.c b/src/stdlib/SDL_getenv.c
index 0cd4405..10fa7c5 100644
--- a/src/stdlib/SDL_getenv.c
+++ b/src/stdlib/SDL_getenv.c
@@ -20,10 +20,13 @@
*/
#include "SDL_config.h"
+#if defined(__WIN32__)
+#include "../core/windows/SDL_windows.h"
+#endif
+
#include "SDL_stdinc.h"
#if !defined(SDL_setenv) && defined(__WIN32__)
-#include "../core/windows/SDL_windows.h"
/* Note this isn't thread-safe! */
static char *SDL_envmem = NULL; /* Ugh, memory leak */
static size_t SDL_envmemlen = 0;
diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c
index 981e3cd..3bb2f0a 100644
--- a/src/test/SDL_test_common.c
+++ b/src/test/SDL_test_common.c
@@ -1107,10 +1107,10 @@ SDLTest_PrintEvent(SDL_Event * event)
case SDL_FINGERDOWN:
case SDL_FINGERUP:
- fprintf(stderr, "Finger: %s touch=%lld, finger=%lld, x=%f, y=%f, dx=%f, dy=%f, pressure=%f",
+ fprintf(stderr, "Finger: %s touch=%ld, finger=%ld, x=%f, y=%f, dx=%f, dy=%f, pressure=%f",
(event->type == SDL_FINGERDOWN) ? "down" : "up",
- (long long) event->tfinger.touchId,
- (long long) event->tfinger.fingerId,
+ (long) event->tfinger.touchId,
+ (long) event->tfinger.fingerId,
event->tfinger.x, event->tfinger.y,
event->tfinger.dx, event->tfinger.dy, event->tfinger.pressure);
break;
diff --git a/src/thread/windows/SDL_systhread.c b/src/thread/windows/SDL_systhread.c
index 8efcd50..4386e84 100644
--- a/src/thread/windows/SDL_systhread.c
+++ b/src/thread/windows/SDL_systhread.c
@@ -116,8 +116,8 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
int
SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
{
- pfnSDL_CurrentBeginThread pfnBeginThread = _beginthreadex;
- pfnSDL_CurrentEndThread pfnEndThread = _endthreadex;
+ pfnSDL_CurrentBeginThread pfnBeginThread = (pfnSDL_CurrentBeginThread)_beginthreadex;
+ pfnSDL_CurrentEndThread pfnEndThread = (pfnSDL_CurrentEndThread)_endthreadex;
#endif /* SDL_PASSED_BEGINTHREAD_ENDTHREAD */
pThreadStartParms pThreadParms =
(pThreadStartParms) SDL_malloc(sizeof(tThreadStartParms));
diff --git a/src/thread/windows/SDL_systls.c b/src/thread/windows/SDL_systls.c
index 0ece77d..90941ee 100644
--- a/src/thread/windows/SDL_systls.c
+++ b/src/thread/windows/SDL_systls.c
@@ -20,13 +20,13 @@
*/
#include "SDL_config.h"
-#include "SDL_thread.h"
-#include "../SDL_thread_c.h"
#if SDL_THREAD_WINDOWS
#include "../../core/windows/SDL_windows.h"
+#include "SDL_thread.h"
+#include "../SDL_thread_c.h"
static DWORD thread_local_storage = TLS_OUT_OF_INDEXES;
static SDL_bool generic_local_storage = SDL_FALSE;
diff --git a/src/video/windows/SDL_windowsmessagebox.c b/src/video/windows/SDL_windowsmessagebox.c
index f544259..e50c542 100644
--- a/src/video/windows/SDL_windowsmessagebox.c
+++ b/src/video/windows/SDL_windowsmessagebox.c
@@ -22,7 +22,11 @@
#if SDL_VIDEO_DRIVER_WINDOWS
-#include "SDL.h"
+#if defined(__WIN32__)
+#include "../../core/windows/SDL_windows.h"
+#endif
+
+#include "SDL_assert.h"
#include "SDL_windowsvideo.h"
diff --git a/src/video/windows/SDL_windowsvideo.h b/src/video/windows/SDL_windowsvideo.h
index b00d713..ff2b4a2 100644
--- a/src/video/windows/SDL_windowsvideo.h
+++ b/src/video/windows/SDL_windowsvideo.h
@@ -23,10 +23,10 @@
#ifndef _SDL_windowsvideo_h
#define _SDL_windowsvideo_h
-#include "../SDL_sysvideo.h"
-
#include "../../core/windows/SDL_windows.h"
+#include "../SDL_sysvideo.h"
+
#if defined(_MSC_VER)
#include <msctf.h>
#else
diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c
index 0c5e5bb..cd53975 100644
--- a/src/video/windows/SDL_windowswindow.c
+++ b/src/video/windows/SDL_windowswindow.c
@@ -22,6 +22,8 @@
#if SDL_VIDEO_DRIVER_WINDOWS
+#include "../../core/windows/SDL_windows.h"
+
#include "SDL_assert.h"
#include "../SDL_sysvideo.h"
#include "../SDL_pixels_c.h"
diff --git a/test/configure b/test/configure
index 94a2f13..136606c 100755
--- a/test/configure
+++ b/test/configure
@@ -3452,7 +3452,7 @@ rm -f core conftest.err conftest.$ac_objext \
rm -f conf.sdltest
CFLAGS="$CFLAGS $SDL_CFLAGS"
-LIBS="$LIBS $SDL_LIBS -lSDL2_test"
+LIBS="$LIBS -lSDL2_test $SDL_LIBS"
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
diff --git a/test/configure.in b/test/configure.in
index a186097..eb30287 100644
--- a/test/configure.in
+++ b/test/configure.in
@@ -86,7 +86,7 @@ AM_PATH_SDL2($SDL_VERSION,
AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
)
CFLAGS="$CFLAGS $SDL_CFLAGS"
-LIBS="$LIBS $SDL_LIBS -lSDL2_test"
+LIBS="$LIBS -lSDL2_test $SDL_LIBS"
dnl Check for X11 path, needed for OpenGL on some systems
AC_PATH_X