table of contents
- testing 3.2.4+ds-2
- unstable 3.2.4+ds-2
- experimental 3.2.4+git20250228+ds-1
SDL_enabled_assert(3) | SDL3 FUNCTIONS | SDL_enabled_assert(3) |
NAME¶
SDL_enabled_assert - The macro used when an assertion is enabled.
HEADER FILE¶
Defined in SDL3/SDL_assert.h
SYNOPSIS¶
#include "SDL3/SDL.h"
#define SDL_enabled_assert(condition) .BI do{.BI while ( !(condition) ) { .BI staticstructSDL_AssertDatasdl_assert_data={0,0,#condition,0,0,0,0};.BI const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); .BI if(sdl_assert_state==SDL_ASSERTION_RETRY){.BI continue; /* go again. */ .BI }elseif(sdl_assert_state==SDL_ASSERTION_BREAK){.BI SDL_AssertBreakpoint(); .BI }.BI break; /* not retrying. */ .BI }.BI } while (SDL_NULL_WHILE_LOOP_CONDITION)
DESCRIPTION¶
This isn't for direct use by apps, but this is the code that is
inserted when an SDL_assert
is enabled.
The do{}while(0) avoids dangling else problems:
-
if (x) SDL_assert(y); else blah();
... without the do/while, the "else" could attach to this macro's "if". We try to handle just the minimum we need here in a macro...the loop, the static vars, and break points. The heavy lifting is handled in
SDL_ReportAssertion ().
AVAILABILITY¶
This macro is available since SDL 3.2.0.
SDL 3.2.5 | Simple Directmedia Layer |