Init, errors & main callbacksSDL 3.2
SDL_GetError
Returns a readable message about the last SDL error on this thread.
Signature
const char * SDL_GetError(void);
How it works
Most SDL3 functions return false or NULL when they fail, and store the reason as text. SDL_GetError reads that text.
Check the return value FIRST. SDL does not clear the message when a call succeeds, so a non-empty SDL_GetError() on its own proves nothing: it may be an old message, or an internal warning from a call that worked.
Return value
The message (empty string if none). It stays valid until the next error on this thread; copy it to keep it.
Example
example.cpp
1SDL_Texture* tex = SDL_CreateTextureFromSurface(renderer, surface);
2if (!tex) { // check the result first
3 SDL_Log("texture failed: %s", SDL_GetError());
4}