ATOMIC_VAR_INIT

ATOMIC_VAR_INIT

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).

References

  • C11 standard (ISO/IEC 9899:2011):
    • 7.17.2.1 The ATOMIC_VAR_INIT macro (p: 274)

See also

(C11)
initializes a new atomic_flag
(macro constant)

© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/c/atomic/ATOMIC_VAR_INIT

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部