SDL Wiki


Use this macro to create an assertion for debugging.


void SDL_assert(condition)

Function Parameters


the expression to check

Code Examples

SDL_assert(1 == 0);  // triggers an assertion.
SDL_assert(1 == 1);  // does NOT trigger an assertion.


This function is enabled only when the SDL_ASSERT_LEVEL is set to 2 or 3, otherwise it is disabled. See the Assertions Category page for details.

One can set the environment variable "SDL_ASSERT" to one of several strings ("abort", "break", "retry", "ignore", "always_ignore") to force a default behavior, which may be desirable for automation purposes. If your platform requires GUI interfaces to happen on the main thread but you're debugging an assertion in a background thread, it might be desirable to set this to "break" so that your debugger takes control as soon as assert is triggered, instead of risking a bad UI interaction (deadlock, etc) in the application.

Note that the SDL_ASSERT environment variable is an environment variable and not an SDL hint! Please refer to your platform's documentation for how to set it!


CategoryAPI, CategoryAssertions

[ 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.