Re: using C11's _Atomic()

[email protected] (Tony Cook) Mon, 4 May 2026 11:39:59 +1000
Newsgroups perl.perl5.porters
Message-ID <[email protected]>
On Mon, May 04, 2026 at 02:25:34AM +0200, Leon Timmermans wrote:
> That can be worked around by using std::atomic<int> instead of _Atomic(int)
> in C++ mode (and including atomic).

I couldn't find anything that indicated they were guaranteed to be
compatible - does an _Atomic<long long> have the same ABI as
atomic<long long>?

They do provide all the same type aliases though, so if they aren't
compatible C++ code that uses <atomic> and <stdatomic.h> is going to
be painful.

I saw one claim that it is UB:

https://stackoverflow.com/questions/53898429/interoperabilty-between-c-and-c-atomics#answer-53898931

but they might be wrong.

Tony