VS2005 tweaks (thanks, Ozkan!). Fixes Bugzilla #2895. His notes: The following trivial changes make SDL2 tree (mostly) compatible with Visual Studio 2005: * SDL_stdlib.c: Similar to VS2010 and newer, VS2005 also generates memcpy(), (it also generates memset(), see below), so propagate the #if condition to cover VS2005. * SDL_pixels.c (SDL_CalculateGammaRamp): VS2005 generates a memset() call for gamma==0 case, so replace the if loop with SDL_memset(). * SDL_windowsvideo.h: Include msctf.h only with VS2008 and newer, otherwise include SDL_msctf.h * SDL_windowskeyboard.c: Adjust the #ifdefs so that SDL_msctf.h inclusion is always recognized correctly.
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
diff --git a/src/stdlib/SDL_stdlib.c b/src/stdlib/SDL_stdlib.c
index 65fee8c..24b2b27 100644
--- a/src/stdlib/SDL_stdlib.c
+++ b/src/stdlib/SDL_stdlib.c
@@ -279,7 +279,8 @@ __declspec(selectany) int _fltused = 1;
#endif
/* The optimizer on Visual Studio 2010/2012 generates memcpy() calls */
-#if _MSC_VER >= 1600 && defined(_WIN64) && !defined(_DEBUG)
+/* Visual Studio 2005 does it too, and it also generates memset() calls */
+#if (_MSC_VER == 1400 || _MSC_VER >= 1600) && defined(_WIN64) && !defined(_DEBUG)
#include <intrin.h>
#pragma function(memcpy)
diff --git a/src/video/SDL_pixels.c b/src/video/SDL_pixels.c
index 44b811a..6b96125 100644
--- a/src/video/SDL_pixels.c
+++ b/src/video/SDL_pixels.c
@@ -1101,9 +1101,7 @@ SDL_CalculateGammaRamp(float gamma, Uint16 * ramp)
/* 0.0 gamma is all black */
if (gamma == 0.0f) {
- for (i = 0; i < 256; ++i) {
- ramp[i] = 0;
- }
+ SDL_memset(ramp, 0, 256 * sizeof(Uint16));
return;
} else if (gamma == 1.0f) {
/* 1.0 gamma is identity */
diff --git a/src/video/windows/SDL_windowskeyboard.c b/src/video/windows/SDL_windowskeyboard.c
index a9f063f..edc2b9a 100644
--- a/src/video/windows/SDL_windowskeyboard.c
+++ b/src/video/windows/SDL_windowskeyboard.c
@@ -211,7 +211,12 @@ void IME_Present(SDL_VideoData *videodata)
#else
-#ifdef __GNUC__
+#ifdef _SDL_msctf_h
+#define USE_INIT_GUID
+#elif defined(__GNUC__)
+#define USE_INIT_GUID
+#endif
+#ifdef USE_INIT_GUID
#undef DEFINE_GUID
#define DEFINE_GUID(n,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) static const GUID n = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}
DEFINE_GUID(IID_ITfInputProcessorProfileActivationSink, 0x71C6E74E,0x0F28,0x11D8,0xA8,0x2A,0x00,0x06,0x5B,0x84,0x43,0x5C);
diff --git a/src/video/windows/SDL_windowsvideo.h b/src/video/windows/SDL_windowsvideo.h
index 8a1cd5a..e8ba37e 100644
--- a/src/video/windows/SDL_windowsvideo.h
+++ b/src/video/windows/SDL_windowsvideo.h
@@ -27,7 +27,7 @@
#include "../SDL_sysvideo.h"
-#if defined(_MSC_VER)
+#if defined(_MSC_VER) && (_MSC_VER >= 1500)
#include <msctf.h>
#else
#include "SDL_msctf.h"