From 6cb0a4c1b0b2cb65ae8f3bfb122edead0e94f3fc Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 6 Mar 2015 02:57:09 +0200 Subject: 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. --- backends/platform/sdl/sdl-sys.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) 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 #else @@ -67,6 +86,22 @@ typedef struct { int FAKE; } FAKE_FILE; #endif #include + +// 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 -- cgit v1.2.3