API reference / Application
SDL_GetError
Function, SDL3
Gets a message that describes the last error in SDL. Call it just after a function reports a failure.
Declaration
#include <SDL3/SDL.h>
const char * SDL_GetError(void);Return value
A string with the message. With no error, the string is empty.
Example
SDL_Log("SDL_Init failed: %s", SDL_GetError());See this code run in Open a window. Download the full program (.zip)
Notes
- A success does not clear the message. So test the return value of a function first, and call this only after a failure.
In SDL2
The name is the same.