There is nothing we can do There is nothing we can do - 3 months ago 64
C++ Question

Enabling C++14 in clang in Visual Studio

I've installed clang 3.7 and I'm using it with visual studio. When I try to compile:

auto f()
return 2;

I'm getting error saying that this is future from C++14. I've tried to pass:

-std=c++14 as compiler arguments but then I'm getting error:

Error 1 error : unknown argument: '-std=c++14' C:\Users...\visual studio 2013\Projects\ConsoleApplication8\ConsoleApplication8\clang-cl.exe ConsoleApplication8.

Any ideas how to enable c++14 features in clang under Visual Studio 2013?


I have to add that I am able to compile and build c++11 code with this compiler under Visual Studio without any problems.


clang-cl doesn't use the same option syntax as traditional clang - it's supposed to mimic Visual Studio's cl command line, not clang's command line.

For instance, from clang-cl's documentation:

  /?                     Display available options
  /arch:<value>          Set architecture for code generation
  /C                     Don't discard comments when preprocessing
  /c                     Compile only
  /D <macro[=value]>     Define macro

However, they have a little pass-through option to support cases like yours:

  -Xclang <arg>         Pass <arg> to the clang compiler
  -mllvm <value>        Additional arguments to forward to LLVM's option processing

And so it would seem that invoking clang-cl -Xclang -std=c++14 would be your best bet.