This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/60932] make stdatomic.h compatible with C++


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++.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]