First question
I found on cppreference
_Atomic ( type-name )
(since C11)Use as a type specifier; this designates a new atomic type
_Atomic type-name
(2) (since C11)Use as a type qualifier; this designates the atomic version of type-name. In this role, it may be mixed with const, volatile, and restrict), although unlike other qualifiers, the atomic version of type-name may have a different size, alignment, and object representation.
So does using _Atomic(int)
instead of _Atomic int
guarantee it to be the same size as int
or not?
Second question
Using a qualifier inside _Atomic
Ex:
_Atomic(volatile int)
Throws an error, but using it like this:
_Atomic(volatile _Atomic(int)*)
Does not; is this standard behaviour?
Last question
I noticed atomic functions (ex: atomic_store
, atomic_load
, atomic_compare_exchange_weak
) work without the passed types being _Atomic
types, and I can still manage race conditions with no problem.
Is this standard behaviour? Does it have downsides or lead to any error?