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?
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++.
You can use Clang in C17 mode with the -std=c17 or -std=c18 options (available in Clang 6 and later).
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With