---
name: "SDL_COMPILE_TIME_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_COMPILE_TIME_ASSERT"
---

# SDL\_COMPILE\_TIME\_ASSERT(3)

A compile-time assertion.

## NAME

SDL\_COMPILE\_TIME\_ASSERT - A compile-time assertion.

## HEADER FILE

Defined in SDL3/SDL\_stdinc.h

## SYNOPSIS

```
#include "SDL3/SDL.h"
```

**#define SDL\_COMPILE\_TIME\_ASSERT(name, x) FailToCompileIf\_x\_IsFalse(x)**

## DESCRIPTION

This can check constant values \_known to the compiler at build time\_ for correctness, and end the compile with the error if they fail.

Often times these are used to verify basic truths, like the size of a datatype is what is expected:

-

  ```
  SDL_COMPILE_TIME_ASSERT(uint32_size, sizeof(Uint32) == 4);
  ```

The **name** parameter must be a valid C symbol, and must be unique across all compile-time asserts in the same compilation unit (one run of the compiler), or the build might fail with cryptic errors on some targets. This is used with a C language trick that works on older compilers that don't support better assertion techniques.

If you need an assertion that operates at runtime, on variable data, you should try  **SDL\_assert**\
  instead.

## THREAD SAFETY

This macro doesn't generate any code to run.

## AVAILABILITY

This macro is available since SDL 3.2.0.

## SEE ALSO

**•**(3), [**SDL\_assert**(3)](/SDL_assert/3.md)
