From 790cd395f54f458303fb3b4a4f8ed4fd62719e55 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 7 Mar 2024 06:35:23 -0800 Subject: [PATCH] Make sure the type in the SDL_Event aligns properly across the union --- include/SDL3/SDL_events.h | 6 +++++- src/events/SDL_events.c | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/SDL3/SDL_events.h b/include/SDL3/SDL_events.h index 3c133f5a9c..ec7002e562 100644 --- a/include/SDL3/SDL_events.h +++ b/include/SDL3/SDL_events.h @@ -227,7 +227,11 @@ typedef enum /** * This last event is only for bounding internal arrays */ - SDL_EVENT_LAST = 0xFFFF + SDL_EVENT_LAST = 0xFFFF, + + /* This just makes sure the enum is the size of Uint32 */ + SDL_EVENT_ENUM_PADDING = 0x7FFFFFFF + } SDL_EventType; /** diff --git a/src/events/SDL_events.c b/src/events/SDL_events.c index b5c05c7e1b..01d126350a 100644 --- a/src/events/SDL_events.c +++ b/src/events/SDL_events.c @@ -48,6 +48,9 @@ /* Determines how often we wake to call SDL_PumpEvents() in SDL_WaitEventTimeout_Device() */ #define PERIODIC_POLL_INTERVAL_NS (3 * SDL_NS_PER_SECOND) +/* Make sure the type in the SDL_Event aligns properly across the union */ +SDL_COMPILE_TIME_ASSERT(SDL_Event_type, sizeof(Uint32) == sizeof(SDL_EventType)); + typedef struct SDL_EventWatcher { SDL_EventFilter callback;