# ATOMIC_FLAG_INIT

> C++ Atlas: `cppatlas.com/w/c/atomic/ATOMIC_FLAG_INIT` | Source: https://en.cppreference.com/w/c/atomic/ATOMIC_FLAG_INIT | Domain: Atomic operations | Standards: C11, C17, C23

Expands to an initializer that can be used to initialize atomic_flag type to the clear state. The value of an atomic_flag that is not initialized using this macro is indeterminate.

## Official Specification Summary (cppreference)

```cpp
// Defined in header <stdatomic.h>
#define ATOMIC_FLAG_INIT /* unspecified */ // (since C11)
```

Expands to an initializer that can be used to initialize `atomic_flag` type to the clear state. The value of an `atomic_flag` that is not initialized using this macro is indeterminate.

### Example

```c
#include <stdatomic.h>

atomic_flag flag = ATOMIC_FLAG_INIT;
```

### References

- C17 standard (ISO/IEC 9899:2018):

  - 7.17.1/3 ATOMIC_FLAG_INIT (p: 200)

  - 7.17.8/4 ATOMIC_FLAG_INIT (p: 208)

- C11 standard (ISO/IEC 9899:2011):

  - 7.17.1/3 ATOMIC_FLAG_INIT (p: 273)

  - 7.17.8/4 ATOMIC_FLAG_INIT (p: 285)

### See also

- [`ATOMIC_VAR_INIT`](https://en.cppreference.com/w/c/atomic/ATOMIC_VAR_INIT) (C11): initializes a new atomic object (function macro)
- [`atomic_flag`](https://en.cppreference.com/w/c/atomic/atomic_flag) (C11): lock-free atomic boolean flag (struct)
- [C++ documentation for `ATOMIC_FLAG_INIT`](https://en.cppreference.com/w/cpp/atomic/ATOMIC_FLAG_INIT)

---
Attribution: content from https://en.cppreference.com/w/c/atomic/ATOMIC_FLAG_INIT (cppreference.com), licensed under CC-BY-SA 3.0 and GFDL. Modified: converted to markdown, study notes added. Offline snapshot of 9 February 2025.