Although there are some questions here concerning the C++11 support of clang, I don't seem to be able to get clang++
to eat my C++11 code.
$ clang++ --version clang version 2.9 (tags/RELEASE_29/final) Target: x86_64-pc-linux-gnu Thread model: posix
According to the clang C++11 status page I should have at least partial support (e.g. right angle brackets), but it refuses all features I tested.
Is there any switch to tell clang to use C++11?
Example test:
$ clang++ -stdlib=libstdc++ cpp11.cpp cpp11.cpp:16:33: error: a space is required between consecutive right angle brackets (use '> >') std::vector<std::pair<int,char>> xs; ^~ > > cpp11.cpp:18:8: error: C++ requires a type specifier for all declarations auto y = x; ~~~~ ^ 2 errors generated
To activate C++11, you have to add -std=c++11 in your clang calls, like for gcc. If you use an IDE that is clang-aware or gcc-aware, there is a specific project settings option available to do that.
Clang is C++14 feature complete.
C++20 implementation statusClang has support for some of the features of the ISO C++ 2020 standard. You can use Clang in C++20 mode with the -std=c++20 option (use -std=c++2a in Clang 9 and earlier).
ildjarn points out the correct argument, -std=c++0x
or -std=c++11
. The errors you're getting with that argument may be because the version of libstdc++ you're using uses some C++11, or non-standard C++, that clang 2.9 doesn't support.
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