All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SDL_assert.h File Reference
#include "SDL_config.h"
#include "begin_code.h"
#include "close_code.h"

Go to the source code of this file.


struct  SDL_assert_data


#define SDL_assert(condition)   SDL_disabled_assert(condition)
#define SDL_assert_always(condition)   SDL_enabled_assert(condition)
#define SDL_ASSERT_LEVEL   1
#define SDL_assert_paranoid(condition)   SDL_disabled_assert(condition)
#define SDL_assert_release(condition)   SDL_enabled_assert(condition)
#define SDL_disabled_assert(condition)   do { (void) sizeof ((condition)); } while (SDL_NULL_WHILE_LOOP_CONDITION)
#define SDL_enabled_assert(condition)
#define SDL_FILE   __FILE__
#define SDL_FUNCTION   "???"
#define SDL_LINE   __LINE__
#define SDL_TriggerBreakpoint()


typedef struct SDL_assert_data SDL_assert_data
typedef SDL_assert_state(SDLCALLSDL_AssertionHandler )(const SDL_assert_data *data, void *userdata)


enum  SDL_assert_state {


DECLSPEC const SDL_assert_data
SDL_GetAssertionReport (void)
 Get a list of all assertion failures. More...
DECLSPEC SDL_assert_state SDLCALL SDL_ReportAssertion (SDL_assert_data *, const char *, const char *, int)
DECLSPEC void SDLCALL SDL_ResetAssertionReport (void)
 Reset the list of all assertion failures. More...
DECLSPEC void SDLCALL SDL_SetAssertionHandler (SDL_AssertionHandler handler, void *userdata)
 Set an application-defined assertion handler. More...

Macro Definition Documentation

#define SDL_assert_always (   condition)    SDL_enabled_assert(condition)

Definition at line 175 of file SDL_assert.h.

#define SDL_ASSERT_LEVEL   1

Definition at line 40 of file SDL_assert.h.

#define SDL_assert_paranoid (   condition)    SDL_disabled_assert(condition)

Definition at line 161 of file SDL_assert.h.

#define SDL_assert_release (   condition)    SDL_enabled_assert(condition)

Definition at line 160 of file SDL_assert.h.

#define SDL_disabled_assert (   condition)    do { (void) sizeof ((condition)); } while (SDL_NULL_WHILE_LOOP_CONDITION)

Definition at line 95 of file SDL_assert.h.

#define SDL_enabled_assert (   condition)
do { \
while ( !(condition) ) { \
static struct SDL_assert_data assert_data = { \
0, 0, #condition, 0, 0, 0, 0 \
}; \
if (state == SDL_ASSERTION_RETRY) { \
continue; /* go again. */ \
} else if (state == SDL_ASSERTION_BREAK) { \
} \
break; /* not retrying. */ \
} \
GLenum condition
Definition: gl2ext.h:1403
Definition: SDL_assert.h:98
#define SDL_LINE
Definition: SDL_assert.h:72
#define SDL_FILE
Definition: SDL_assert.h:71
#define SDL_TriggerBreakpoint()
Definition: SDL_assert.h:61
Definition: SDL_assert.h:69
Definition: SDL_assert.h:92
#define const
Definition: zconf.h:91
DECLSPEC SDL_assert_state SDLCALL SDL_ReportAssertion(SDL_assert_data *, const char *, const char *, int)
Definition: SDL_assert.c:259

Definition at line 132 of file SDL_assert.h.

#define SDL_FILE   __FILE__

Definition at line 71 of file SDL_assert.h.

#define SDL_FUNCTION   "???"

Definition at line 69 of file SDL_assert.h.

#define SDL_LINE   __LINE__

Definition at line 72 of file SDL_assert.h.


Definition at line 92 of file SDL_assert.h.

#define SDL_TriggerBreakpoint ( )

Definition at line 61 of file SDL_assert.h.

Typedef Documentation

typedef SDL_assert_state(SDLCALL * SDL_AssertionHandler)(const SDL_assert_data *data, void *userdata)

Definition at line 178 of file SDL_assert.h.

Enumeration Type Documentation


Retry the assert immediately.


Make the debugger trigger a breakpoint.


Terminate the program.


Ignore the assert.


Ignore the assert from now on.

Definition at line 98 of file SDL_assert.h.

Function Documentation

DECLSPEC const SDL_assert_data* SDLCALL SDL_GetAssertionReport ( void  )

Get a list of all assertion failures.

Get all assertions triggered since last call to SDL_ResetAssertionReport(), or the start of the program.

The proper way to examine this data looks something like this:

const SDL_assert_data *item = SDL_GetAssertionReport(); while (item) { printf("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\n", item->condition, item->function, item->filename, item->linenum, item->trigger_count, item->always_ignore ? "yes" : "no"); item = item->next; }

List of all assertions.
See Also

Definition at line 348 of file SDL_assert.c.

References triggered_assertions.

DECLSPEC void SDLCALL SDL_ResetAssertionReport ( void  )

Reset the list of all assertion failures.

Reset list of all assertions triggered.

See Also

Definition at line 353 of file SDL_assert.c.

References SDL_assert_data::always_ignore, SDL_assert_data::next, NULL, SDL_FALSE, and SDL_assert_data::trigger_count.

Referenced by SDL_GenerateAssertionReport().

DECLSPEC void SDLCALL SDL_SetAssertionHandler ( SDL_AssertionHandler  handler,
void userdata 

Set an application-defined assertion handler.

This allows an app to show its own assertion UI and/or force the response to an assertion failure. If the app doesn't provide this, SDL will try to do the right thing, popping up a system-specific GUI dialog, and probably minimizing any fullscreen windows.

This callback may fire from any thread, but it runs wrapped in a mutex, so it will only fire from one thread at a time.

Setting the callback to NULL restores SDL's original internal handler.

This callback is NOT reset to SDL's internal handler upon SDL_Quit()!

SDL_assert_state value of how to handle the assertion failure.
handlerCallback function, called when an assertion fails.
userdataA pointer passed to the callback as-is.

Definition at line 337 of file SDL_assert.c.

References assertion_handler, assertion_userdata, NULL, and SDL_PromptAssertion().