SDL_assert_always(3)
π SDL_assert_always β the assert that NEVER takes a day off π
okay bestie, welcome to the SDL_assert_always page from the SDL3 functions manual πΈ yes it's a 3 page, yes it's a macro, yes we're gonna get into it.
β¨ NAME β¨
SDL_assert_always β an assertion test that is always performed. no days off. no skipping. she's committed. π
π SYNOPSIS π
#include <SDL3/SDL_assert.h>
#define SDL_assert_always(condition) SDL_enabled_assert(condition)
literally the whole thing. a macro that hands off to SDL_enabled_assert. that's it, that's the girl π¦
π DESCRIPTION π
so here's the tea β this macro is always enabled, no matter what SDL_ASSERT_LEVEL is set to. like, you cannot turn her off. she shows up to every party, invited or not.
π¨ and that is exactly why you almost never want to use this. bestie. listen. this can trigger on an end-user's system and crash your program. not your dev machine, not your test rig β a real person's real computer. ngl that's giving main character energy in the worst way possible π
okay but here's a thing you can do: you can set the environment variable "SDL_ASSERT" to one of several strings β "abort", "break", "retry", "ignore", "always_ignore" β to force a default behavior. which honestly can be super desirable for automation purposes π€
and here's a specific little scenario that's lowkey iconic: 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 the assert is triggered β instead of risking a bad UI interaction (deadlock, etc.) in the application. deadlocks are NOT the vibe π
π«Ά MACRO PARAMETERS π«Ά
conditionβ boolean value to test. that's the whole parameter. that's her. β¨
π THREAD SAFETY π
it is safe to call this macro from any thread. any of them. all of them. go off, queen π
β AVAILABILITY β
this macro has been available since SDL 3.2.0. vintage-ish but make it fresh π
okay that's the page!! source is Simple Directmedia Layer, version SDL 3.4.18, and we're flipping through it in the SDL 3 era, dated with all the love of a SDL_assert_always(3) footer π remember: assert responsibly, don't crash your users' computers, and set "SDL_ASSERT" to "break" when you're debugging off the main thread. mwah πβ¨
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms