How to compile C++ for Windows with clang in Visual Studio 2015

As far as I understand it both Clang and GCC are shipped with the Android and iOS crossplatform SDKs/tools for Visual Studio 2015.

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:

enter image description here

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. enter image description here

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.

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.

Caveat: This answer is pre-VS2015 update 1 which didn't have the "Clang with Microsoft CodeGen" option.


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.

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.


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.

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.

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

There's more information in this blog post.

screenshot of the new project window