Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      ATOMIC_VAR_INIT

      From cppreference.com
      <c‎ |atomic
       
       
      Concurrency support library
       
      Defined in header<stdatomic.h>
      #define ATOMIC_VAR_INIT(value) /* unspecified */
      (since C11)
      (deprecated in C17)
      (removed in C23)

      Expands to an expression that can be used to initialize an atomic variable of the same type asvalue.

      The initial value of atomic object of automatic storage duration that is not explicitly initialized is indeterminate. The default (zero) initialization of static and thread-local variables produces a valid value however.

      When initializing an atomic variable, any concurrent access, even through an atomic operation, is a data race (it may happen if the address is immediately passed to another thread with amemory_order_relaxed operation).

      Contents

      [edit]Notes

      This macro was a part of early draft design for C11 atomic types. It is not needed in C11, and is deprecated in C17 and removed in C23.

      [edit]Defect reports

      The following behavior-changing defect reports were applied retroactively to previously published C standards.

      DRApplied toBehavior as publishedCorrect behavior
      DR 485C11the specification was redundant and contradictory to the core languagefixed

      [edit]References

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

      [edit]See also

      initializes a newatomic_flag
      (macro constant)[edit]
      C++ documentation forATOMIC_VAR_INIT
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=c/atomic/ATOMIC_VAR_INIT&oldid=140123"

      [8]ページ先頭

      ©2009-2026 Movatter.jp