Namespaces
Variants
Views
Actions

ATOMIC_VAR_INIT

From cppreference.com
< c‎ | atomic
Revision as of 17:35, 9 July 2013 by P12bot (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Defined in header <stdatomic.h>
#define ATOMIC_VAR_INIT(value) /* unspecified */
(since C11)

Expands to an expression that can be used to initialize an atomic variable of the same type as value. The initial value of atomic object of automatic storage duration that is not initialized using this macro is undefined. The default (zero) initialization of static and thread-local variables produces valid value however.

If this macro is not used for initialization of an atomic variable, any accesses during initialization from another thread, even through an atomic operation, is a data race (it may happen if the address is immediately passed to another thread with a memory_order_relaxed operation).

[edit] See also

initializes a new atomic_flag
(macro constant) [edit]