{"id":9245,"date":"2016-06-07T10:15:27","date_gmt":"2016-06-07T17:15:27","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vcblog\/?p=9245"},"modified":"2019-02-18T18:04:47","modified_gmt":"2019-02-18T18:04:47","slug":"standards-version-switches-in-the-compiler","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/standards-version-switches-in-the-compiler\/","title":{"rendered":"Standards version switches in the compiler"},"content":{"rendered":"<p>Shareable link: <a href=\"https:\/\/aka.ms\/versionswitches\">https:\/\/aka.ms\/versionswitches<\/a>\n<a href=\"https:\/\/docs.microsoft.com\/cpp\/build\/reference\/std-specify-language-standard-version\">Official documentation on docs.microsoft.com<\/a>. <\/p>\n<p><em>This blog post written by Gabriel Dos Reis, Ulzii Luvsanbat, and Andrew Pardoe.<\/em><\/p>\n<p>In\u00a0<a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/2016\/06\/07\/visual-studio-2015-update-3-rc\/\">Visual C++ 2015 Update 3<\/a> we are introducing tools to help you control the version of the ISO C++ programming language you depend on and the version you want VC++ to enforce in your projects. We&#8217;re creating a series of new switches that correspond to versions of the C++ language, starting with <code><a href=\"#c++14\">\/std:c++14<\/a><\/code> and <code><a href=\"#c++latest\">\/std:c++latest<\/a><\/code>.<\/p>\n<h3>Why add these switches?<\/h3>\n<p>Traditionally, we would release the compiler in a default mode that combines features striding several versions of the C++ language, e.g. C++98, C++03, C++11, C++14, etc. in addition to conformance improvement bug fixes. This can lead to situations where it is difficult to simultaneously upgrade to the newer and better compiler and at the same time move your code forward. We really appreciate the great feedback you\u2019ve given us about our conformance improvements and new feature work. As the C++ standards committee is gearing up for a new C++ version, we\u2019ve taken the initiative to help you state in your build systems or compiler command lines which version of C++ you are comfortable with while updating to the next version of Visual C++.<\/p>\n<p>Visual C++\u00a0has made significant progress towards C++ standards conformance between the first release of Visual Studio 2015 and VS 2015 Update 3. We\u2019ve fixed many issues with <a href=\"https:\/\/blogs.msdn.microsoft.com\/vcblog\/2016\/02\/11\/compiler-improvements-in-vs-2015-update-2\/\"><code>constexpr<\/code>, improved expression SFINAE support, evaluation of initializer lists, variable templates<\/a>, and more. Our <a href=\"https:\/\/blogs.msdn.microsoft.com\/vcblog\/2016\/01\/22\/vs-2015-update-2s-stl-is-c17-so-far-feature-complete\/\">standard library implementation has kept pace with features adopted into the post-C++14 standard draft<\/a>. And we\u2019ve implemented some major features currently under consideration by the committee, including <a href=\"https:\/\/blogs.msdn.microsoft.com\/vcblog\/2015\/12\/03\/c-modules-in-vs-2015-update-1\/\">C++ modules<\/a> and <a href=\"https:\/\/blogs.msdn.microsoft.com\/vcblog\/2015\/11\/30\/coroutines-in-visual-studio-2015-update-1\/\">coroutines<\/a>. We want you to benefit from all this, but also we want you to consume these features at your own pace, while upgrading to this new update.<\/p>\n<p>All post-C++14 features implemented in this update are off by default; those which were included in previous releases are left on to avoid causing your builds.<\/p>\n<h3>Switches for language versions<\/h3>\n<p>We want to help you keep your compiler toolchains up to date with the newest versions of Visual Studio. To help you stay current without requiring you to immediately move your code to the latest C++ standards we\u2019re introducing a series of switches that allow you to opt-in to versions of the C++ standard. As we\u2019re starting with VS 2015 Update 3, the first switch in the series will be <code>\/std:c++14<\/code>, reflecting the state of the Visual C++ compiler today. We also introduce a <code>\/std:c++latest<\/code> switch that will reflect compiler and library work proposed in the current standard draft. Note that similar switches are available in other compilers, including <a href=\"https:\/\/gcc.gnu.org\">GCC <\/a>and <a href=\"http:\/\/clang.llvm.org\/\">Clang<\/a>.<\/p>\n<p>The switches enable new features from each C++ Standard, or any behavior breaking changes on existing features. They are not meant to track MSVC-specific conformance bugs. Bug fixes will continue to happen independently of language version switches. If\u00a0a bug fix prompts source code changes to be more standards conformant, the compiler will provide well-defined diagnostic messages. And we\u2019ll continue to keep an extremely high bar for bug fixes that require source code changes, and we\u2019ll continue to document each fix and its impact (this page lists the\u00a0existing <a href=\"https:\/\/msdn.microsoft.com\/library\/mt723604.aspx\">compiler conformance improvements<\/a> documentation for VS 2015.)<\/p>\n<p><a><\/a><\/p>\n<h3>\/std:c++14<\/h3>\n<p>The <code>\/std:c++14<\/code> switch enables the set of C++14 features implemented by the Visual C++ compiler, modulo conformance bug fixes and ongoing feature work (such as for <span style=\"font-family: Courier New\">constexpr<\/span>, expression SFINAE, 2-phase name lookup, etc.) Using the \/std:c++14 switch will always instruct Visual C++ to compile your code according to the C++14 standards and associated Defect Reports.\u00a0\u00a0This is the default language version in this update.<\/p>\n<p>Each version of the C++ Standard generally builds upon previous versions, except when they don\u2019t. Consequently, each language version (for versions after C++14, because we are starting with <code>\/std:c++14<\/code>) will select C++14 semantics in addition to any other requirements (including feature modification or removal) instructed by that language version. Using a later switch in the series such as <code>\/std:c++latest<\/code> (see the section on <code><a href=\"#c++14\">\/std:c++latest<\/a><\/code> below) will turn on post-C++14 features in addition to C++14 features. Note that there is no plan to add a\u00a0C++11 switch.<\/p>\n<p>There are some post-C++14 features already implemented in previous releases of the Visual C++ compiler. To avoid breaking changes for users who have already taken dependencies on these features we\u2019ll leave them under the <code>\/std:c++14<\/code> switch. They include the following features, all of which have already shipped in Visual Studio 2015 Update 2:<\/p>\n<ul>\n<li><a href=\"http:\/\/www.open-std.org\/jtc1\/sc22\/wg21\/docs\/papers\/2014\/n3922.html\">New rules for auto with braced-init-lists<\/a><\/li>\n<li><a href=\"http:\/\/www.open-std.org\/jtc1\/sc22\/wg21\/docs\/papers\/2014\/n4051.html\">typename in template template-parameters<\/a><\/li>\n<li><a href=\"http:\/\/www.open-std.org\/jtc1\/sc22\/wg21\/docs\/papers\/2014\/n4086.html\">Removing trigraphs<\/a><\/li>\n<li><a href=\"http:\/\/www.open-std.org\/jtc1\/sc22\/wg21\/docs\/papers\/2014\/n4266.html\">Attributes for namespaces and enumerators<\/a><\/li>\n<li><a href=\"http:\/\/www.open-std.org\/jtc1\/sc22\/wg21\/docs\/papers\/2014\/n4267.html\">u8 character literals<\/a><\/li>\n<\/ul>\n<p>Note that some library features from C++17, such as <code>std::is_convertible_v<\/code> were also already implemented before the standards version switches were created and thus appear under <code>\/std:c++14<\/code>.\n<a><\/a><\/p>\n<h3>\/std:c++latest<\/h3>\n<p>The <code>\/std:c++latest<\/code> switch will move forward the set of features implemented by Visual C++ with each new version of the C++ standards Working Draft. Currently it will track features that we add for the proposed post-C++14 draft standard. When the next standard is approved, the semantics opted-in with the <code>\/std:c++latest<\/code> will be covered by <code>\/std:c++17<\/code> (assuming that the next standard is C++17, but the standards committee working group\u00a0never ceases to surprise) and <code>\/std:c++latest<\/code> will move forward to track the next draft standard\u2019s features. In another words, with \/std:c++latest, you will always get the set of all new features currently implemented and on by default. (The <code>\/std:c++latest<\/code> switch will not turn on new features guarded by the <code>\/experimental<\/code> switch.)<\/p>\n<h3>Summary<\/h3>\n<p>Visual Studio 2015 Update 3 introduces two new switches (<code>\/std:c++14<\/code> and <code>\/std:c++latest<\/code>) to give you control over the version of the C++ programming language you want to use in your projects. In this update, if you specify a language version that isn\u2019t any of those, the compiler will ignore the switch (with a warning) and default to C++14. You can try the compiler out today&#8211;see this blog post for details on how to get the VS 2015 Update 3 RC:\u00a0<a href=\"https:\/\/devblogs.microsoft.com\/visualstudio\/2016\/06\/07\/visual-studio-2015-update-3-rc\/\">https:\/\/devblogs.microsoft.com\/visualstudio\/2016\/06\/07\/visual-studio-2015-update-3-rc\/<\/a><\/p>\n<h3>In closing<\/h3>\n<p>As always, we\u2019re eager for you to try out the changes and give us feedback in the comments below, by email at <a href=\"mailto:visualcpp@microsoft.com\">visualcpp@microsoft.com<\/a>, or through any of the usual channels: <a href=\"http:\/\/visualstudio.uservoice.com\/forums\/121579-visual-studio-2015\">User Voice<\/a>, <a href=\"http:\/\/visualstudio.uservoice.com\/forums\/121579-visual-studio-2015\">Suggestions<\/a>, <a href=\"https:\/\/connect.microsoft.com\/visualstudio\">Connect<\/a> (for bugs), or even <a href=\"http:\/\/go.microsoft.com\/fwlink\/?LinkId=517102\">Send-A-Smile<\/a>. We love hearing from you!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Shareable link: https:\/\/aka.ms\/versionswitches Official documentation on docs.microsoft.com. This blog post written by Gabriel Dos Reis, Ulzii Luvsanbat, and Andrew Pardoe. In\u00a0Visual C++ 2015 Update 3 we are introducing tools to help you control the version of the ISO C++ programming language you depend on and the version you want VC++ to enforce in your projects. [&hellip;]<\/p>\n","protected":false},"author":312,"featured_media":35994,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[140,100,242,151],"class_list":["post-9245","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cplusplus","tag-c","tag-c-language","tag-connect2016","tag-iso-c"],"acf":[],"blog_post_summary":"<p>Shareable link: https:\/\/aka.ms\/versionswitches Official documentation on docs.microsoft.com. This blog post written by Gabriel Dos Reis, Ulzii Luvsanbat, and Andrew Pardoe. In\u00a0Visual C++ 2015 Update 3 we are introducing tools to help you control the version of the ISO C++ programming language you depend on and the version you want VC++ to enforce in your projects. [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/9245","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\/312"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=9245"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/9245\/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=9245"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=9245"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=9245"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}