Type assertions

Someone was worried that the SDL typedefs for Uint32 etc weren’t always
correct. The right way to fix that is to use autoconf, but here’s an
alternative (works for both SDL itself and clients using the headers)

diff -u -r1.4.2.4 SDL_types.h
— include/SDL_types.h 2000/10/12 20:33:11 1.4.2.4
+++ include/SDL_types.h 2000/12/16 21:34:31
@@ -64,6 +64,21 @@
} Uint64, Sint64;
#endif

+/* Make sure the types really have the right sizes */
+#define SDL_COMPILE_TIME_ASSERT(name, x) \

  •   typedef int SDL_dummy_ ## name[(x) * 2 - 1]+
    

+SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1);
+SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1);
+SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2);
+SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2);
+SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4);
+SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4);
+SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8);
+SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8);
+
+#undef SDL_COMPILE_TIME_ASSERT
+
/* General keyboard/mouse state definitions */
enum { SDL_PRESSED = 0x01, SDL_RELEASED = 0x00 };