Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clang 3.1 and C++11 support status

Tags:

From clang's C++11 support status website, http://clang.llvm.org/cxx_status.html , it says, "Initializer List" and "Lambda Expression" are all supported starting from version 3.1.

However, using LLVM/Clang trunk (3.2), compiling against initializer list and lambda expression will yield error messages.

Does anyone know if Clang >3.1 supports those features?

like image 459
will Avatar asked May 15 '12 13:05

will


People also ask

Does Clang support C ++ 11?

C++11 implementation statusYou can use Clang in C++11 mode with the -std=c++11 option. Clang's C++11 mode can be used with libc++ or with gcc's libstdc++.

Does Clang support C 17?

You can use Clang in C17 mode with the -std=c17 or -std=c18 options (available in Clang 6 and later).

What is Clang latest version?

Clang 14, the latest major version of Clang as of March 2022, has full support for all published C++ standards up to C++17, implements most features of C++20, and has initial support for the upcoming C++23 standard.

Is Clang GCC compatible?

Yes, for C code Clang and GCC are compatible (they both use the GNU Toolchain for linking, in fact.) You just have to make sure that you tell clang to create compiled objects and not intermediate bitcode objects. C ABI is well-defined, so the only issue is storage format.


1 Answers

By default, clang++ will not enable the C++11 features - you have to pass an additional flag during compilation.

clang++ -std=c++11 [input files...] 

Or

# enables some additional C++11 extensions GCC has clang++ -std=gnu++11 [input files...]  

Additionally, you can switch between using libstdc++ and Clang's own libc++, which are different implementations of the C++ standard library. libc++ in some cases might have a better implementation of the C++11 standard than your existing libstdc++ library.

# uses clang's C++ library in C++98 mode clang++ -stdlib=libc++ [input] # uses clang's C++ library  # uses clang's C++ library and enables C++11 mode clang++ -stdlib=libc++ -std=c++11 [input]  

The latter is important if you're using Clang in an environment with an outdated version of libstdc++ (like Mac OSX), but note that the two C++ libraries are not compatible with each other, so you would have to rebuild any dependencies against libc++ if you were to use that.

like image 149
逆さま Avatar answered Sep 17 '22 18:09

逆さま