This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/60932] make stdatomic.h compatible with C++
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 23 Apr 2014 12:57:31 +0000
- Subject: [Bug c++/60932] make stdatomic.h compatible with C++
- Auto-submitted: auto-generated
- References: <bug-60932-4 at http dot gcc dot gnu dot org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60932
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Sebastian Huber from comment #4)
> It is clear that you cannot use C++ header files from C. So if you want to
> provide a library intended for C and C++ applications you must use C as the
> base line. With this C++ incompatible <stdatomic.h> you cannot do this for
> applications requiring atomic operations. So you are forced to provide two
> implementations.
Not true, I think this should work fine:
#ifdef __cplusplus
#include <atomic>
using namespace std;
#else
#include <stdatomic.h>
#endif
atomic<int> i;
int main()
{
atomic_store(&i, 0);
return atomic_load(&i);
}
The fact it doesn't looks like a problem with libstdc++'s <atomic> not
<stdatomic.h>
I don't think we want to support the _Atomic qualifier in C++.