Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

clang++ C++11 invocation

Tags:

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 
like image 232
bitmask Avatar asked Nov 28 '11 23:11

bitmask


People also ask

How do I enable C ++ 11 in Clang?

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.

What version of C does Clang use?

Clang is C++14 feature complete.

Does Clang fully support C ++ 20?

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).


1 Answers

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.

like image 96
bames53 Avatar answered Oct 05 '22 12:10

bames53