As far as I understand, Visual Studio 2015 is shipped with clang. First I though this was only for Android and iOS apps, but according to this article it should also be possible to use the clang++ frontend for Windows programs. However, I can't find the according option.
据我所知,Visual Studio 2015是与clang一起发布的。首先,我认为这只适用于Android和iOS应用程序,但根据本文,在Windows程序中使用clang+ frontend也应该是可能的。但是,我找不到根据选项。
So could you please explain to me, how I can change the used compiler to clang in a c++ project (in VS2015 RC Community Edition).
所以你能给我解释一下,我如何在一个c++项目(VS2015 RC Community Edition)中把用过的编译器改成clang。
4 个解决方案
#1
23
Starting with VS2015 Update 1 you can install the "Clang with Microsoft CodeGen" template via the New Project window, browse to Installed -> Templates -> Visual C++ -> Cross Platform.
从VS2015升级1开始,您可以通过新的项目窗口安装“带有Microsoft CodeGen的Clang”模板,浏览到已安装的->模板-> Visual c++ ->交叉平台。
You will then be able to choose the Clang 3.7 with Microsoft CodeGen v140_clang_3_7
Platform Toolset in the properties page of any Windows C++ project.
然后,您将能够在任何Windows c++项目的属性页中使用Microsoft CodeGen v140_clang_3_7平台工具集选择Clang 3.7。
Clang has a completely different set of command-line options which it recognizes, so when using the v140_clang_3_7
toolset, the project properties must be using Clang-compatible options, which can be recognized as starting with -
instead of /
. For example, Debug Information Format property set to "Full Debug Information (DWARF2) (-g2 -gdwarf-2
)", and Enable C++ Exceptions property set to "Yes (-fexceptions
)".
Clang有一组完全不同的命令行选项,它可以识别这些选项,所以当使用v140_clang_3_7工具集时,项目属性必须使用与Clang兼容的选项,可以识别为以-开头,而不是/开头。例如,Debug Information Format属性设置为“完全调试信息(dwarf f2) (-g2 -gdwarf-2)”,并启用设置为“Yes (-fexception)”的c++异常属性。
There's more information in this blog post.
这篇博文里有更多的信息。
#2
8
As far as I understand it both Clang and GCC are shipped with the Android and iOS crossplatform SDKs/tools for Visual Studio 2015.
据我所知,Clang和GCC都附带了Visual Studio 2015的Android和iOS交叉splatform SDKs/tools。
From what I've seen it only allows me to choose those while having one of those crossplatform projects.
从我所看到的情况来看,它只允许我在拥有一个这样的交叉项目时选择它们。
Using the template project for a GLES C++ application you get the following options:
使用GLES c++应用程序的模板项目,您将获得以下选项:
While for a Windows C++ application you get the dialog below where you can see that Windows target platform is grayed out and read-only, meaning you probably have a set of toolkits for each target platform, but you simply cannot change it, at least for now.
对于Windows c++应用程序,您可以看到下面的对话框,其中的Windows目标平台是灰色和只读的,这意味着您可能为每个目标平台都有一组工具包,但您根本无法更改它,至少目前是这样。
Have no idea how you turn a normal VS project into crossplatform though, and it's likely that you can only target Android or iOS out of the box using 3rd party compilers.
你不知道如何将一个普通的VS项目转换成交叉格式,很可能你只能使用第三方编译器来锁定Android或iOS。
It may be possible, though, to install Clang as another toolkit in the same way the XP toolkits are. So perhaps it's just a matter of someone fiddling with it and making it available as it is already installed.
不过,也有可能以与XP工具包相同的方式将Clang安装为另一个工具包。所以,也许只是有人在摆弄它,并在它已经安装的时候让它可用。
#3
3
After reading through the linked post and especially the comments again, I came to understand, that this is not a feature shipped with VS2015 RC but a possible future feature that might e.g. be shipped in a SP or (more likely) with the next version of VS.
在阅读了链接的文章,尤其是评论之后,我明白了,这并不是VS2015 RC附带的特性,而是一个可能的未来特性,例如,可以在SP中发布,或者(更有可能)在VS的下一个版本中发布。
As mentioned by sjdowling, the closest thing you can do at the moment (October 2015, clang 3.7) is to download and install llvm for windows. This should give you a LLVM-vs2014 platform toolset option. For me it works for simple test programs, but apparently this version of "clang-vs" seems to not yet support exceptions. However, according to these notes, that problem should be mostly solved for clang 3.8.
正如sjdowling所提到的,目前最接近的事情(2015年10月,clang 3.7)是为windows下载并安装llvm。这将为您提供一个LLVM-vs2014平台工具集选项。对我来说,它适用于简单的测试程序,但显然这个版本的“铿锵—vs”似乎还不支持异常。但是,根据这些说明,clang 3.8应该主要解决这个问题。
#4
0
While the above solutions work they require that you have installed clang which is off by default in the visual studio 2015 installation. The accepted answer does show how to install it, though the next page will ask you to close visual studio which you are running the new project from.
在上面的解决方案中,他们要求您安装了clang,在visual studio 2015安装中默认是关闭的。接受的答案确实显示了如何安装它,不过下一页将要求你关闭你正在运行的新项目的visual studio。
If anyone is wondering how to install clang because it does not show up in their list here is another solution:
如果有人想知道如何安装clang,因为它没有出现在他们的列表中,这里有另一个解决方案:
- Control Panel->Programs->Programs and Features.
- 控制面板- >程序- >程序和功能。
- Right click on “Microsoft Visual Studio Enterprise 2015” (or “Microsoft Visual
- 右键点击“Microsoft Visual Studio Enterprise 2015”(或“Microsoft Visual”)
- Studio 15 Preview” if you have the preview of the next version of Visual Studio installed)
- Studio 15预览“如果你已经安装了下一个版本的Visual Studio预览版”
- Click “Change”
- 点击“更改”
- Click “Modify”
- 点击“修改”
- Select “Clang with Microsoft CodeGen” – The March 2016 release.
- 选择“与微软代码生成的铿锵”——2016年3月发布。
https://blogs.msdn.microsoft.com/vcblog/2016/03/31/clang-with-microsoft-codegen-march-2016-released/
https://blogs.msdn.microsoft.com/vcblog/2016/03/31/clang - -微软codegen - 3月- 2016 released/
#1
23
Starting with VS2015 Update 1 you can install the "Clang with Microsoft CodeGen" template via the New Project window, browse to Installed -> Templates -> Visual C++ -> Cross Platform.
从VS2015升级1开始,您可以通过新的项目窗口安装“带有Microsoft CodeGen的Clang”模板,浏览到已安装的->模板-> Visual c++ ->交叉平台。
You will then be able to choose the Clang 3.7 with Microsoft CodeGen v140_clang_3_7
Platform Toolset in the properties page of any Windows C++ project.
然后,您将能够在任何Windows c++项目的属性页中使用Microsoft CodeGen v140_clang_3_7平台工具集选择Clang 3.7。
Clang has a completely different set of command-line options which it recognizes, so when using the v140_clang_3_7
toolset, the project properties must be using Clang-compatible options, which can be recognized as starting with -
instead of /
. For example, Debug Information Format property set to "Full Debug Information (DWARF2) (-g2 -gdwarf-2
)", and Enable C++ Exceptions property set to "Yes (-fexceptions
)".
Clang有一组完全不同的命令行选项,它可以识别这些选项,所以当使用v140_clang_3_7工具集时,项目属性必须使用与Clang兼容的选项,可以识别为以-开头,而不是/开头。例如,Debug Information Format属性设置为“完全调试信息(dwarf f2) (-g2 -gdwarf-2)”,并启用设置为“Yes (-fexception)”的c++异常属性。
There's more information in this blog post.
这篇博文里有更多的信息。
#2
8
As far as I understand it both Clang and GCC are shipped with the Android and iOS crossplatform SDKs/tools for Visual Studio 2015.
据我所知,Clang和GCC都附带了Visual Studio 2015的Android和iOS交叉splatform SDKs/tools。
From what I've seen it only allows me to choose those while having one of those crossplatform projects.
从我所看到的情况来看,它只允许我在拥有一个这样的交叉项目时选择它们。
Using the template project for a GLES C++ application you get the following options:
使用GLES c++应用程序的模板项目,您将获得以下选项:
While for a Windows C++ application you get the dialog below where you can see that Windows target platform is grayed out and read-only, meaning you probably have a set of toolkits for each target platform, but you simply cannot change it, at least for now.
对于Windows c++应用程序,您可以看到下面的对话框,其中的Windows目标平台是灰色和只读的,这意味着您可能为每个目标平台都有一组工具包,但您根本无法更改它,至少目前是这样。
Have no idea how you turn a normal VS project into crossplatform though, and it's likely that you can only target Android or iOS out of the box using 3rd party compilers.
你不知道如何将一个普通的VS项目转换成交叉格式,很可能你只能使用第三方编译器来锁定Android或iOS。
It may be possible, though, to install Clang as another toolkit in the same way the XP toolkits are. So perhaps it's just a matter of someone fiddling with it and making it available as it is already installed.
不过,也有可能以与XP工具包相同的方式将Clang安装为另一个工具包。所以,也许只是有人在摆弄它,并在它已经安装的时候让它可用。
#3
3
After reading through the linked post and especially the comments again, I came to understand, that this is not a feature shipped with VS2015 RC but a possible future feature that might e.g. be shipped in a SP or (more likely) with the next version of VS.
在阅读了链接的文章,尤其是评论之后,我明白了,这并不是VS2015 RC附带的特性,而是一个可能的未来特性,例如,可以在SP中发布,或者(更有可能)在VS的下一个版本中发布。
As mentioned by sjdowling, the closest thing you can do at the moment (October 2015, clang 3.7) is to download and install llvm for windows. This should give you a LLVM-vs2014 platform toolset option. For me it works for simple test programs, but apparently this version of "clang-vs" seems to not yet support exceptions. However, according to these notes, that problem should be mostly solved for clang 3.8.
正如sjdowling所提到的,目前最接近的事情(2015年10月,clang 3.7)是为windows下载并安装llvm。这将为您提供一个LLVM-vs2014平台工具集选项。对我来说,它适用于简单的测试程序,但显然这个版本的“铿锵—vs”似乎还不支持异常。但是,根据这些说明,clang 3.8应该主要解决这个问题。
#4
0
While the above solutions work they require that you have installed clang which is off by default in the visual studio 2015 installation. The accepted answer does show how to install it, though the next page will ask you to close visual studio which you are running the new project from.
在上面的解决方案中,他们要求您安装了clang,在visual studio 2015安装中默认是关闭的。接受的答案确实显示了如何安装它,不过下一页将要求你关闭你正在运行的新项目的visual studio。
If anyone is wondering how to install clang because it does not show up in their list here is another solution:
如果有人想知道如何安装clang,因为它没有出现在他们的列表中,这里有另一个解决方案:
- Control Panel->Programs->Programs and Features.
- 控制面板- >程序- >程序和功能。
- Right click on “Microsoft Visual Studio Enterprise 2015” (or “Microsoft Visual
- 右键点击“Microsoft Visual Studio Enterprise 2015”(或“Microsoft Visual”)
- Studio 15 Preview” if you have the preview of the next version of Visual Studio installed)
- Studio 15预览“如果你已经安装了下一个版本的Visual Studio预览版”
- Click “Change”
- 点击“更改”
- Click “Modify”
- 点击“修改”
- Select “Clang with Microsoft CodeGen” – The March 2016 release.
- 选择“与微软代码生成的铿锵”——2016年3月发布。
https://blogs.msdn.microsoft.com/vcblog/2016/03/31/clang-with-microsoft-codegen-march-2016-released/
https://blogs.msdn.microsoft.com/vcblog/2016/03/31/clang - -微软codegen - 3月- 2016 released/