and use fallback only for C.
It fixes the isssue with clang-cl:
#include <stdatomic.h> #include <stdbool.h> #ifdef __cplusplus #include <atomic> using namespace std; #endif int main() { atomic_bool b = true; }
$ clang-cl /TC main.cpp # works
$ clang-cl /TP /std:c++20 main.cpp stdatomic.h(70,6): error: conflicting types for 'atomic_thread_fence' void atomic_thread_fence(memory_order); ^ atomic(166,24): note: previous definition is here extern "C" inline void atomic_thread_fence(const memory_order _Order) noexcept { ... fatal error: too many errors emitted, stopping now [-ferror-limit=] 20 errors generated.
Many errors but
<stdatomic.h> has many macros to built-in functions.
#define atomic_thread_fence(order) __c11_atomic_thread_fence(order)
and MSVC <atomic> has real functions.
and the built-in functions are redefined.