atomic type specifier and qualifier

From cppreference.com
< c‎ | language

Implements the atomic type for data that are shared among threads.

Contents

[edit] Syntax

_Atomic ( type-name )
_Atomic

[edit] Explanation

If the _Atomic keyword is immediately followed by a left parenthesis, it is interpreted as a type specifier (with a type name), not as a type qualifier.

The type name in an atomic type specifier shall not refer to an array type, a function type, an atomic type, or a qualified type.

The type modified by the _Atomic qualifier shall not be an array type or a function type.

If the conditional feature macro __STDC_NO_ATOMICS__ is defined, then the implementation does not support atomic types (including the _Atomic type qualifier) and the <stdatomic.h> header.

[edit] Keywords

_Atomic

[edit] Example

An atomic object and a pointer to a volatile-qualified atomic type.

int main(void)
{
    _Atomic(int) counter;      /* atomic type specifier */
    _Atomic volatile int *p;   /* atomic type qualifier */
}

Possible output:

(none)