在Visual Studio中的Clang中启用C ++ 14 [英] Enabling C++14 in clang in Visual Studio

查看:324
本文介绍了在Visual Studio中的Clang中启用C ++ 14的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了clang 3.7,并且已在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;
}

我误会说这是C ++ 14的未来。我尝试通过:

-std = c ++ 14作为编译器参数,但随后出现错误:

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:

错误1错误:未知参数:'-std = c ++ 14' C:\Users ... \visual studio 2013\Projects\ConsoleApplication8\ConsoleApplication8\clang-cl.exe ConsoleApplication8。

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

有什么想法如何在Visual Studio 2013下在clang中启用c ++ 14功能?

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

编辑:

我必须补充一点,我能够在Visual Studio下使用此编译器编译和构建c ++ 11代码,而不会出现任何问题。


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 不使用与传统clang相同的选项语法-应该模仿Visual Studio的 cl 命令行,而不是 clang 的命令行。

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.

例如,来自 clang-cl 文档

CL.EXE COMPATIBILITY OPTIONS:
  /?                     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
  ...

请注意,这些选项类似于Microsoft的 cl 选项语法,而不是 clang 的选项语法。

Notice that those options are similar to Microsoft's cl option syntax, not clang's option syntax.

但是,他们有一些传递选项来支持像您这样的案例:

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

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

因此,调用 clang-cl -Xclang -std = c ++ 14 是您最好的选择。

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

这篇关于在Visual Studio中的Clang中启用C ++ 14的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆