{"id":13395,"date":"2017-03-07T10:05:25","date_gmt":"2017-03-07T17:05:25","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vcblog\/?p=13395"},"modified":"2021-01-05T10:11:04","modified_gmt":"2021-01-05T10:11:04","slug":"use-any-c-compiler-with-visual-studio","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/use-any-c-compiler-with-visual-studio\/","title":{"rendered":"Use any C++ Compiler with Visual Studio"},"content":{"rendered":"<p>Microsoft Visual Studio 2017 supports several C++ compilers to suit a wide variety of codebases.\u00a0 In addition to the Microsoft Visual C++ compiler that many of you are likely familiar with, Visual Studio 2017 also supports Clang, GCC, and other compilers when targeting certain platforms.<\/p>\n<p>This post is intended to familiarize you with the variety of C++ compilers that are compatible with the Visual Studio IDE, and to understand when they might be applicable to use with your projects. \u00a0Some compilers may be better suited to your needs depending on your project or target.\u00a0 Alternatively, you may be interested in checking out new language features, such as <a href=\"https:\/\/blogs.msdn.microsoft.com\/vcblog\/2017\/02\/22\/learn-c-concepts-with-visual-studio-and-the-wsl\/\">C++ Concepts<\/a>, that are not available across all compilers without needing to leave the IDE.<\/p>\n<p>You can select the compiler and corresponding toolset that will be used to build a project with the \u201cPlatform Toolset\u201d property under General Configuration Properties for C++ projects.\u00a0 Any installed compilers that are applicable to your project type will be listed in the \u201cPlatform Toolset\u201d dropdown.<\/p>\n<h3>Microsoft C++ Compiler (MSVC)<\/h3>\n<p>If you are targeting Windows, the Microsoft C++ compiler (MSVC) may be the way to go.\u00a0 This is the default compiler for most Visual Studio C++ projects and is <a href=\"https:\/\/devblogs.microsoft.com\/vcblog\/\/07\/msvc-the-best-choice-for-windows\">recommended if you are targeting Windows<\/a>.<\/p>\n<p><figure id=\"attachment_13405\" aria-labelledby=\"figcaption_attachment_13405\" class=\"wp-caption alignnone\" ><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/MSVC-All-Options.png\"><img decoding=\"async\" class=\"wp-image-13405 size-full\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/MSVC-All-Options.png\" alt=\"Compiler options for the Microsoft C++ compiler.\" width=\"838\" height=\"597\" \/><\/a><figcaption id=\"figcaption_attachment_13405\" class=\"wp-caption-text\">Compiler options for the Microsoft C++ compiler.<\/figcaption><\/figure><\/p>\n<h3>Clang<\/h3>\n<p>You can use the Clang compiler with Visual Studio to target Android, iOS, and Windows.<\/p>\n<p>If you are targeting Android, you can use the Clang\/LLVM compiler that ships with the Android NDK and toolchain to build your project.\u00a0 Likewise, Visual Studio can use Clang running on a Mac to build projects targeting iOS.\u00a0 Support for Android and iOS is included in the \u201cMobile Development with C++\u201d workload. \u00a0For more information about targeting Android or iOS check out our posts tagged with the keywords \u201c<a href=\"https:\/\/blogs.msdn.microsoft.com\/vcblog\/tag\/android\/\">Android<\/a>\u201d and \u201c<a href=\"https:\/\/blogs.msdn.microsoft.com\/vcblog\/tag\/ios\/\">iOS<\/a>\u201d.<\/p>\n<p>If you are targeting Windows, you have a few options:<\/p>\n<ol>\n<li>Use <a href=\"http:\/\/releases.llvm.org\/download.html\">Clang\/LLVM<\/a>; \u201cClang for Windows\u201d includes instructions to install Clang\/LLVM as a platform toolset in Visual Studio.<\/li>\n<li>Use Clang to target Windows with Clang\/C2 (Clang frontend with Microsoft Code Generation).<\/li>\n<\/ol>\n<p><figure id=\"attachment_13415\" aria-labelledby=\"figcaption_attachment_13415\" class=\"wp-caption alignnone\" ><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/Clang-C2-All-Options.png\"><img decoding=\"async\" class=\"wp-image-13415 size-full\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/Clang-C2-All-Options.png\" alt=\"Compiler options for the Clang\/C2 compiler.\" width=\"838\" height=\"597\" \/><\/a><figcaption id=\"figcaption_attachment_13415\" class=\"wp-caption-text\">Compiler options for the Clang\/C2 compiler.<\/figcaption><\/figure><\/p>\n<p>It might make sense to use Clang\/C2 if you want to bring a codebase that takes advantage of Clang&#8217;s language features to the Windows platform.\u00a0 Since the code generation and optimization is handled by the MSVC backend, binaries produced by Clang\/C2 are fully compatible with binaries produced by MSVC.\u00a0 You can learn more about Clang\/C2 from <a href=\"https:\/\/blogs.msdn.microsoft.com\/vcblog\/2015\/12\/04\/clang-with-microsoft-codegen-in-vs-2015-update-1\/\">Clang with Microsoft Codegen<\/a> \u2013 or check out the latest updates in posts tagged with the keyword\u00a0<a href=\"https:\/\/blogs.msdn.microsoft.com\/vcblog\/tag\/clang\/\">\u201cclang\u201d<\/a>.<\/p>\n<h3>GCC<\/h3>\n<p>If your project targets Linux or Android, you can consider using GCC.\u00a0 Visual Studio&#8217;s C++ Android development natively supports building your projects with the GCC that ships with the Android NDK, just like it does for Clang.\u00a0 You can also target Linux &#8211; either remotely or locally with the <a href=\"https:\/\/blogs.msdn.microsoft.com\/wsl\/\">Windows Subsystem for Linux<\/a> \u2013 with GCC.<\/p>\n<p><figure id=\"attachment_13425\" aria-labelledby=\"figcaption_attachment_13425\" class=\"wp-caption alignnone\" ><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/GCC-Remote-All-Options.png\"><img decoding=\"async\" class=\"size-full wp-image-13425\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/9\/2019\/02\/GCC-Remote-All-Options.png\" alt=\"Compiler options for GCC.\" width=\"838\" height=\"597\" \/><\/a><figcaption id=\"figcaption_attachment_13425\" class=\"wp-caption-text\">Compiler options for GCC.<\/figcaption><\/figure><\/p>\n<p>Check out our post on <a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/linux-development-with-c-in-visual-studio\/\">Visual C++ for Linux Development<\/a> for much more info about how to use Visual Studio to target Linux with GCC.\u00a0 If you are specifically interested in targeting WSL locally, check out <a href=\"https:\/\/blogs.msdn.microsoft.com\/vcblog\/2017\/02\/08\/targeting-windows-subsystem-for-linux-from-visual-studio\/\">Targeting WSL\u00a0from Visual Studio<\/a>.<\/p>\n<h3>Closing<\/h3>\n<p>Visual Studio also makes use of the <a href=\"https:\/\/www.edg.com\/c\">Edison Design Group<\/a> (EDG) frontend to provide flexible IntelliSense regardless of whether you use MSVC, Clang, or GCC to build your code. \u00a0Visual Studio gives you access to a wide range of choices when it comes to C++ compilers. \u00a0This way you can make sure that as you develop your code, it continues to compile against all major compilers.<\/p>\n<p><a href=\"https:\/\/aka.ms\/vs2017cpp\">Install Visual Studio<\/a> today and give it a try. \u00a0Please let us know if we have missed any compilers you use, and share your feedback as we look forward to improving your C++ development experience.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Microsoft Visual Studio 2017 supports several C++ compilers to suit a wide variety of codebases.\u00a0 In addition to the Microsoft Visual C++ compiler that many of you are likely familiar with, Visual Studio 2017 also supports Clang, GCC, and other compilers when targeting certain platforms. This post is intended to familiarize you with the variety [&hellip;]<\/p>\n","protected":false},"author":326,"featured_media":35994,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-13395","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cplusplus"],"acf":[],"blog_post_summary":"<p>Microsoft Visual Studio 2017 supports several C++ compilers to suit a wide variety of codebases.\u00a0 In addition to the Microsoft Visual C++ compiler that many of you are likely familiar with, Visual Studio 2017 also supports Clang, GCC, and other compilers when targeting certain platforms. This post is intended to familiarize you with the variety [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/13395","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/users\/326"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=13395"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/13395\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media\/35994"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media?parent=13395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=13395"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=13395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}