SDL School

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

Open a window
SDL_Log("SDL_Init failed: %s", SDL_GetError());

See this code run in Open a window. Download the full program (.zip)

Notes

In SDL2

The name is the same.

See also