---
name: "SDL_enabled_assert"
section: "3"
platform: "linux"
package: "libsdl3-doc"
version: "3.2.10+ds-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/SDL_enabled_assert"
---

# SDL\_enabled\_assert(3)

The macro used when an assertion is enabled.

## 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** *static***struct***SDL\_AssertData***sdl\_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* **}***else***if***(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.
