Get Apple clang version and corresponding upstream LLVM version

前端 未结 9 2143
梦如初夏
梦如初夏 2020-12-05 06:25

I want to understand which version of clang Apple installed in my macbook, to see with c++11 and/or c++14 features are available. I typed this command:

clang         


        
9条回答
  •  既然无缘
    2020-12-05 06:57

    The (Apple) version number of the compiler is mostly useless, since you also need to consider whether your code is compiled with libstdc++ or with libc++ (or any other standard library) - and which version of those.

    If you want to test for language or library features, it is better to check other defined values, e.g., __cplusplus, __cpp_constexpr, __cpp_variadic_templates, etc. It is not perfect, but it seems to work better (if you want portability) in my experience and the support from all major compiler is improving.

    Each C++ standard version defines a value for __cplusplus, some compilers use intermediate values to say "we already started on C++14, but we are not there yet". Use >= to test when needed.

    The other feature test macros are similar, you can find the current version at N4440. Not all compilers implement N4440, though.

提交回复
热议问题