diff -urNp SDL-1.2/include/SDL_endian.h~ SDL-1.2/include/SDL_endian.h --- SDL-1.2/include/SDL_endian.h~ 2008-12-08 10:10:34.000000000 +0200 +++ SDL-1.2/include/SDL_endian.h 2009-04-02 09:16:25.000000000 +0300 @@ -150,9 +150,9 @@ static __inline__ Uint64 SDL_Swap64(Uint Uint32 hi, lo; /* Separate into high and low 32-bit values and swap them */ - lo = (Uint32)(x&0xFFFFFFFF); + lo = SDL_static_cast(Uint32, x & 0xFFFFFFFF); x >>= 32; - hi = (Uint32)(x&0xFFFFFFFF); + hi = SDL_static_cast(Uint32, x & 0xFFFFFFFF); x = SDL_Swap32(lo); x <<= 32; x |= SDL_Swap32(hi); diff -urNp SDL-1.2/include/SDL_stdinc.h~ SDL-1.2/include/SDL_stdinc.h --- SDL-1.2/include/SDL_stdinc.h~ 2008-12-08 10:10:34.000000000 +0200 +++ SDL-1.2/include/SDL_stdinc.h 2009-04-02 09:16:25.000000000 +0300 @@ -76,6 +76,16 @@ #define SDL_arraysize(array) (sizeof(array)/sizeof(array[0])) #define SDL_TABLESIZE(table) SDL_arraysize(table) +/* Use proper C++ casts when compiled as C++ to be compatible with the option + -Wold-style-cast of GCC (and -Werror=old-style-cast in GCC 4.2 and above. */ +#ifdef __cplusplus +#define SDL_reinterpret_cast(type, expression) reinterpret_cast(expression) +#define SDL_static_cast(type, expression) static_cast(expression) +#else +#define SDL_reinterpret_cast(type, expression) ((type)(expression)) +#define SDL_static_cast(type, expression) ((type)(expression)) +#endif + /* Basic data types */ typedef enum SDL_bool { SDL_FALSE = 0, @@ -248,7 +258,7 @@ do { \ "cld\n\t" \ "rep ; stosl\n\t" \ : "=&D" (u0), "=&a" (u1), "=&c" (u2) \ - : "0" (dst), "1" (val), "2" ((Uint32)(len)) \ + : "0" (dst), "1" (val), "2" (SDL_static_cast(Uint32, len)) \ : "memory" ); \ } while(0) #endif @@ -257,7 +267,7 @@ do { \ do { \ unsigned _count = (len); \ unsigned _n = (_count + 3) / 4; \ - Uint32 *_p = (Uint32 *)(dst); \ + Uint32 *_p = SDL_static_cast(Uint32 *, dst); \ Uint32 _val = (val); \ switch (_count % 4) { \ case 0: do { *_p++ = _val; \ @@ -287,7 +297,7 @@ do { \ "movsb\n" \ "2:" \ : "=&c" (u0), "=&D" (u1), "=&S" (u2) \ - : "0" ((unsigned)(len)/4), "q" (len), "1" (dst),"2" (src) \ + : "0" (SDL_static_cast(unsigned, len)/4), "q" (len), "1" (dst),"2" (src) \ : "memory" ); \ } while(0) #endif @@ -312,7 +322,7 @@ do { \ "cld\n\t" \ "rep ; movsl" \ : "=&c" (ecx), "=&D" (edi), "=&S" (esi) \ - : "0" ((unsigned)(len)), "1" (dst), "2" (src) \ + : "0" (SDL_static_cast(unsigned, len)), "1" (dst), "2" (src) \ : "memory" ); \ } while(0) #endif @@ -324,8 +334,8 @@ do { \ #define SDL_revcpy(dst, src, len) \ do { \ int u0, u1, u2; \ - char *dstp = (char *)(dst); \ - char *srcp = (char *)(src); \ + char *dstp = SDL_static_cast(char *, dst); \ + char *srcp = SDL_static_cast(char *, src); \ int n = (len); \ if ( n >= 4 ) { \ __asm__ __volatile__ ( \