This is new wiki software and old wiki content. It's a work in progress!
Here's the explanation.
Be gentle, report bugs, leave feedback on pages, or just edit them yourself! Thanks!

SDL Wiki

SDL_GetError

Retrieve a message about the last error that occurred on the current thread.

Syntax

const char* SDL_GetError(void);

Return Value

Returns a message with information about the specific error that occurred, or an empty string if there hasn't been an error message set since the last call to SDL_ClearError(). The message is only applicable when an SDL function has signaled an error. You must check the return values of SDL function calls to determine when to appropriately call SDL_GetError().

Remarks

It is possible for multiple errors to occur before calling SDL_GetError(). Only the last error is returned.

The message is only applicable when an SDL function has signaled an error. You must check the return values of SDL function calls to determine when to appropriately call SDL_GetError(). You should _not_ use the results of SDL_GetError() to decide if an error has occurred! Sometimes SDL will set an error string even when reporting success.

SDL will _not_ clear the error string for successful API calls. You _must_ check return values for failure cases before you can assume the error string applies.

Error strings are set per-thread, so an error set in a different thread will not interfere with the current thread's operation.

The returned string is internally allocated and must not be freed by the application.

Code Examples

if (SDL_Init(SDL_INIT_EVERYTHING) < 0) {
    // Unrecoverable error, exit here.
    printf("SDL_Init failed: %s\n", SDL_GetError());
}

Note: Although this example uses SDL_Init(), SDL_GetError() provides an error message for any failed SDL operation which supports error reporting, see the wiki page for each particular SDL function.

SDL_ClearError
SDL_SetError

CategoryAPI, CategoryError


[ edit | delete | history | feedback | raw ]

[ front page | index | search | recent changes | git repo | offline html ]

All wiki content is licensed under Creative Commons Attribution 4.0 International (CC BY 4.0).
Wiki powered by ghwikipp.