simple-stdatomic-for-VS-Clang icon indicating copy to clipboard operation
simple-stdatomic-for-VS-Clang copied to clipboard

_Atomic keyword

Open sphaero opened this issue 4 years ago • 1 comments

Perhaps a naive question but in C11 there's the _Atomic keyword brought in with stdatomic.h.

This library does not cover that but how would one then declare an atomic pointer, ie:

_Atomic     (void*) some_atomic_struct; 

sphaero avatar Oct 31 '20 14:10 sphaero

Good question. However, it is preferred to use atomic_intptr_t or atomic_uintptr_t instead of void*.

So if you wanna operate a pointer, just cast it to atomic_intptr_t. Maybe it is more general and portable. Afterall, C++11 does not contain _Atomic either. :)

zenny-chen avatar Feb 04 '22 14:02 zenny-chen