Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use C++ 11 features in Clang?

Tags:

c++

c++11

clang

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

What version of C does Clang use?

Clang is C++14 feature complete.

Does Clang support C?

The Clang project provides a language front-end and tooling infrastructure for languages in the C language family (C, C++, Objective C/C++, OpenCL, CUDA, and RenderScript) for the LLVM project.

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


You will need clang 3.3 to use the most relevant feature set from C++ 11. Read C++ Support in Clang for the complete list of up-to-date supported features. Clang 3.3 is claimed to be C++11 feature complete.

Clang's command line is gcc-compatible so you have to enable C++11 support via the followinf command-line switch

-std=c++11

There is also a bunch of post-C++11 features (like decltype(auto), member initializers and aggregates) that are supported by Clang 3.3. Use this command line switch to enable them

-std=c++1y

Here is the always up to date list of features supported by clang:

http://clang.llvm.org/cxx_status.html

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.