The clang version I'm using is 3.2.
Clang added atomic support in two different versions in accordance with LLVM CXX Status . The first was Clang 3.1, and the second was Clang 3.2.
I think you can check it using:
#if defined(__clang__) # if __has_feature(cxx_atomic) # define CLANG_CXX11_ATOMICS 1 # endif #endif
Then in your code:
#if CLANG_CXX11_ATOMICS # include <atomic> #endif ... #if defined(CLANG_CXX11_ATOMICS) # define MEMORY_BARRIER() std::atomic_thread_fence(std::memory_order_acq_rel) #elif defined(__GNUC__) || defined(__clang__) # define MEMORY_BARRIER() __asm__ __volatile__ ("" ::: "memory") ... #endif
I can only say "I think" because cxx_atomic not documented in the Clang Language Extensions . However, it is found when searching for the LLVM site: "cxx_atomic" site: llvm.org .
There is also an open question about the CFE user mailing list: How to check for std :: atomic?
Please note that at compile time I include -std = c ++ 11 -stdlib = libc ++. What am I missing?
You can use one of these CLA / LLVM C ++ for this, which is actually just C ++ 03 but pretend to be C ++ 11. This has caused me a lot of problems in the past because we support many compilers and platforms.
The following is a test that Jonathan Wackel helped us create to see if it really was a C ++ 11 library, or one of the fake Apple C ++ 11 libraries:
// Visual Studio began at VS2010, http://msdn.microsoft.com/en-us/library/hh567368%28v=vs.110%29.aspx. // Intel and C++11 language features, http://software.intel.com/en-us/articles/c0x-features-supported-by-intel-c-compiler // GCC and C++11 language features, http://gcc.gnu.org/projects/cxx0x.html // Clang and C++11 language features, http://clang.llvm.org/cxx_status.html
source share