[cpp-threads] Comments on D3193 atomics C compat

Anthony Williams anthony at justsoftwaresolutions.co.uk
Fri Nov 12 11:40:36 GMT 2010


Hi,

I've been reading the latest C compatibility paper D3193, and the notes 
on the reflector.

It is unfortunate that C are insisting on keeping the "_Atomic int" 
style, as this requires a keyword and cannot be built in the library on 
top of existing compiler support for atomics with a different syntax. 
Both _Atomic(int) and atomic<int> can be built on the support from an 
existing compiler, whatever the syntax is.

I do not see _Atomic(x) in the latest draft of D3193. Has it been 
removed? If so, why? Are we relying on the atomic_xyz typedefs for C 
compatibility?

I am not sure how it helps C compatibility to make it implementation 
defined whether or not atomic_int is a typedef for atomic<int> or a base 
class of atomic<int>. That can easily lead to non-portable C++ --- if I 
write my code on an implementation where atomic_int is a typedef then I 
can freely mix atomic<int> and atomic_int all over the place, but this 
may not then compile on an implementation where atomic_int is a base class.

Anthony
-- 
Author of C++ Concurrency in Action     http://www.stdthread.co.uk/book/
just::thread C++0x thread library             http://www.stdthread.co.uk
Just Software Solutions Ltd       http://www.justsoftwaresolutions.co.uk
15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976



More information about the cpp-threads mailing list