http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60932

--- Comment #9 from Sebastian Huber <sebastian.hu...@embedded-brains.de> ---
(In reply to Jonathan Wakely from comment #5)
> (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++.

Ok, but if I create a data structure definition like for example in example.h:

#ifdef __cplusplus
#include <atomic>
using namespace std;
#else
#include <stdatomic.h>
#endif

struct s {
  atomic_int i;
};

Who guarantees that this definition is binary compatible in C and C++?

Reply via email to