[RFC] Make <atomic> and <stdatomic.h> explicitly incompatible

Hello all,

Currently atomics are available in C through <stdatomic.h> and in C++ through . These headers have some common names, so using both of them in the same translation unit usually doesn’t work. The downside is that in some cases diagnostic can be overly verbose and overwhelming. For example, compiling just 2 lines

#include <stdatomic.h>

results in 68 errors.

I am proposing to make these headers explicitly incompatible, so we have just a single error telling so instead of multiple errors. What do you think?

Alternative solution is to make these headers compatible. But the consensus seems to be that it’s not the right solution. See https://reviews.llvm.org/D26376 for more details. There is also a proposal P0943R0: Support C atomics in C++. As far as I can tell, my proposal doesn’t interfere with P0943R0 but will be obsolete if that proposal is accepted. Regardless of the future development I think it is still beneficial to have better diagnostics in the short term.

I am not providing concrete implementation yet, at first I want to know the opinion of the community on the matter.


I’d be in favor of making them explicitly incompatible. I ran into this recently, found the incompatibility quite surprising, and had to do a bunch of research (looking at the relevant standards, doing experiments across a bunch of compilers and standard libraries, etc.) to convince myself that it was expected behavior. An explicit error would be super nice.