aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2015-03-06 02:57:09 +0200
committerFilippos Karapetis2015-03-06 02:57:09 +0200
commit6cb0a4c1b0b2cb65ae8f3bfb122edead0e94f3fc (patch)
tree459342ac4b31acede4b30f1c75645d899e252c76
parent9a494936561a5351f5bfb9e840d70c05684239c3 (diff)
downloadscummvm-rg350-6cb0a4c1b0b2cb65ae8f3bfb122edead0e94f3fc.tar.gz
scummvm-rg350-6cb0a4c1b0b2cb65ae8f3bfb122edead0e94f3fc.tar.bz2
scummvm-rg350-6cb0a4c1b0b2cb65ae8f3bfb122edead0e94f3fc.zip
SDL: Fix compilation with SDL 2.0 under MSVC
In SDL 2.0, intrin.h is now included in SDL_cpuinfo.h, which includes setjmp.h. SDL_cpuinfo.h is included from SDL.h and SDL_syswm.h. Thus, we remove the exceptions for setjmp and longjmp before these two includes.
-rw-r--r--backends/platform/sdl/sdl-sys.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/backends/platform/sdl/sdl-sys.h b/backends/platform/sdl/sdl-sys.h
index 59952323f4..67ad84efd3 100644
--- a/backends/platform/sdl/sdl-sys.h
+++ b/backends/platform/sdl/sdl-sys.h
@@ -60,6 +60,25 @@ typedef struct { int FAKE; } FAKE_FILE;
#undef ARRAYSIZE
#endif
+// HACK to fix compilation with SDL 2.0 in MSVC.
+// In SDL 2.0, intrin.h is now included in SDL_cpuinfo.h, which includes
+// setjmp.h. SDL_cpuinfo.h is included from SDL.h and SDL_syswm.h.
+// Thus, we remove the exceptions for setjmp and longjmp before these two
+// includes. Unfortunately, we can't use SDL_VERSION_ATLEAST here, as SDL.h
+// hasn't been included yet at this point.
+#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && defined(_MSC_VER)
+// We unset any fake definitions of setjmp/longjmp here
+
+#ifndef FORBIDDEN_SYMBOL_EXCEPTION_setjmp
+#undef setjmp
+#endif
+
+#ifndef FORBIDDEN_SYMBOL_EXCEPTION_longjmp
+#undef longjmp
+#endif
+
+#endif
+
#if defined(__SYMBIAN32__)
#include <esdl\SDL.h>
#else
@@ -67,6 +86,22 @@ typedef struct { int FAKE; } FAKE_FILE;
#endif
#include <SDL_syswm.h>
+
+// Restore the forbidden exceptions from the hack above
+#if !defined(FORBIDDEN_SYMBOL_ALLOW_ALL) && defined(_MSC_VER)
+
+#ifndef FORBIDDEN_SYMBOL_EXCEPTION_setjmp
+#undef setjmp
+#define setjmp(a) FORBIDDEN_SYMBOL_REPLACEMENT
+#endif
+
+#ifndef FORBIDDEN_SYMBOL_EXCEPTION_longjmp
+#undef longjmp
+#define longjmp(a,b) FORBIDDEN_SYMBOL_REPLACEMENT
+#endif
+
+#endif
+
// SDL_syswm.h will include windows.h on Win32. We need to undefine its
// ARRAYSIZE definition because we supply our own.
#undef ARRAYSIZE