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

# SDL\_AtomicInt(3type)

A type representing an atomic integer value.

## NAME

SDL\_AtomicInt - A type representing an atomic integer value.

## HEADER FILE

Defined in SDL3/SDL\_atomic.h

## SYNOPSIS

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

**typedef struct SDL\_AtomicInt { int value; } SDL\_AtomicInt;**

## DESCRIPTION

This can be used to manage a value that is synchronized across multiple CPUs without a race condition; when an app sets a value with

**SDL\_SetAtomicInt**\
  all other threads, regardless of the CPU it is running on, will see that value when retrieved with

**SDL\_GetAtomicInt** , regardless of CPU caches, etc.

This is also useful for atomic compare-and-swap operations: a thread can change the value as long as its current value matches expectations. When done in a loop, one can guarantee data consistency across threads without a lock (but the usual warnings apply: if you don't know what you're doing, or you don't do it carefully, you can confidently cause any number of disasters with this, so in most cases, you \_should\_ use a mutex instead of this!).

This is a struct so people don't accidentally use numeric operations on it directly. You have to use SDL atomic functions.

## AVAILABILITY

This struct is available since SDL 3.2.0.

## SEE ALSO

**•**(3), [**SDL\_CompareAndSwapAtomicInt**(3)](/SDL_CompareAndSwapAtomicInt/3.md), **•**(3), [**SDL\_GetAtomicInt**(3)](/SDL_GetAtomicInt/3.md), **•**(3), [**SDL\_SetAtomicInt**(3)](/SDL_SetAtomicInt/3.md), **•**(3), [**SDL\_AddAtomicInt**(3)](/SDL_AddAtomicInt/3.md)
