Add an invalid #define for SDL_ThreadID() to SDL_oldnames.h (#15801)

in SDL2 SDL_ThreadID() was a function that's now
SDL_GetCurrentThreadID(), but in SDL3 SDL_ThreadID is a type, so
in C++ `x = SDL_ThreadID()` is valid code (default constructor which
in case of integers means 0), so that's a massive footgun.

See the big comment in SDL_oldnames.h for more details.

Added `#undef SDL_ThreadID` in SDL_dynapi.c because it has one of the
(quite rare) cases  where "SDL_ThreadID" followed by a "(" is actually
correct and necessary (function pointer returning SDL_ThreadID).
This commit is contained in:
Daniel Gibson
2026-06-12 19:24:56 +02:00
committed by GitHub
parent 4f031ea5da
commit b04d026458
3 changed files with 71 additions and 0 deletions

View File

@@ -55,6 +55,12 @@
#include <windows.h>
#endif
#ifdef SDL_ThreadID
/* prevent the SDL_ThreadID() define from SDL_oldnames.h from breaking
function pointer definitions */
#undef SDL_ThreadID
#endif
/* This is the version of the dynamic API. This doesn't match the SDL version
and should not change until there's been a major revamp in API/ABI.
So 2.0.5 adds functions over 2.0.4? This number doesn't change;