{"id":31267,"date":"2022-11-08T10:30:45","date_gmt":"2022-11-08T10:30:45","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/cppblog\/?p=31267"},"modified":"2022-11-30T17:19:00","modified_gmt":"2022-11-30T17:19:00","slug":"whats-new-for-cpp-developers-in-visual-studio-2022-17-4","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/whats-new-for-cpp-developers-in-visual-studio-2022-17-4\/","title":{"rendered":"What\u2019s New for C++ Developers in Visual Studio 2022 17.4"},"content":{"rendered":"<p>We are happy to announce that Visual Studio 2022 version 17.4 is now generally available! This post summarizes the new features you can find in this release for C++. You can download Visual Studio 2022 from the <a href=\"https:\/\/visualstudio.microsoft.com\/downloads\/\">Visual Studio downloads page <\/a>or upgrade your existing installation by following the <a href=\"https:\/\/learn.microsoft.com\/en-us\/visualstudio\/install\/update-visual-studio?view=vs-2022\">Update Visual Studio Learn page<\/a>.<\/p>\n<h2>Arm64<\/h2>\n<p>In 17.3, Visual Studio became available as a native Arm64 application. We have continued work on supporting more development scenarios and are pleased to announce that the native Arm64 toolchain is now ready for production use!<\/p>\n<p>The \u201cDesktop development with C++\u201d and \u201cGame development with C++\u201d workloads are enabled for native Arm64 development. Please give them a try and let us know your feedback!<\/p>\n<h2>MSVC<\/h2>\n<p>One of our major investments for this release has been in improved compiler diagnostics. New C++ features like concepts and ranges present the opportunity for more expressive code and better-defined APIs. However, to make the most of them, better diagnostics are required from tooling so that constraint failures can be pinpointed and resolved. See Xiang Fan\u2019s blog post on <a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/the-future-of-c-compiler-diagnostics-in-msvc-and-visual-studio\/\">The Future of C++ Compiler Diagnostics in MSVC and Visual Studio<\/a> for all the details, but here\u2019s a quick example of the improvement, showing more complete information on overload resolution failures, and information on why a given constraint failed:<\/p>\n<pre class=\"prettyprint language-cpp\"><code class=\"language-cpp\">struct cat {};\r\nstruct dog {};\r\n\r\n\/\/ can pet cats and dogs\r\nvoid pet(cat);\r\nvoid pet(dog);\r\n\r\ntemplate &lt;class T&gt;\r\nconcept has_member_pettable = requires (T t) { t.pet(); };\r\n\r\n\/\/ allow calling as a non-member\r\ntemplate &lt;has_member_pettable T&gt;\r\nvoid pet(T);\r\n\r\nint main() {\r\n\u00a0 \u00a0 pet(0); \/\/oh no\r\n}<\/code><\/pre>\n<p><strong>Error in 17.3<\/strong><\/p>\n<pre class=\"prettyprint language-default\"><code class=\"language-default\">&lt;source&gt;(16,10): error C2665: 'pet': none of the 2 overloads could convert all the argument types\r\n    pet(0); \/\/oh no\r\n         ^\r\n&lt;source&gt;(6,6): note: could be 'void pet(dog)'\r\nvoid pet(dog);\r\n     ^\r\n&lt;source&gt;(5,6): note: or 'void pet(cat)'\r\nvoid pet(cat);\r\n     ^\r\n&lt;source&gt;(16,5): note: 'void pet(cat)': cannot convert argument 1 from 'int' to 'cat'\r\n    pet(0); \/\/oh no\r\n    ^\r\n&lt;source&gt;(16,10): note: No constructor could take the source type, or constructor overload resolution was ambiguous\r\n    pet(0); \/\/oh no\r\n         ^\r\n&lt;source&gt;(5,6): note: see declaration of 'pet'\r\nvoid pet(cat);\r\n     ^\r\n&lt;source&gt;(16,10): note: while trying to match the argument list '(int)'\r\n    pet(0); \/\/oh no<\/code><\/pre>\n<p><strong>Error in 17.4<\/strong><\/p>\n<pre>&lt;source&gt;(16,5): error C2665: 'pet': no overloaded function could convert all the argument types\r\n    pet(0); \/\/oh no\r\n    ^\r\n&lt;source&gt;(6,6): note: could be 'void pet(dog)'\r\nvoid pet(dog);\r\n     ^\r\n&lt;source&gt;(16,5): note: 'void pet(dog)': cannot convert argument 1 from 'int' to 'dog'\r\n    pet(0); \/\/oh no\r\n    ^\r\n&lt;source&gt;(16,9): note: No constructor could take the source type, or constructor overload resolution was ambiguous\r\n    pet(0); \/\/oh no\r\n        ^\r\n&lt;source&gt;(5,6): note: or 'void pet(cat)'\r\nvoid pet(cat);\r\n     ^\r\n&lt;source&gt;(16,5): note: 'void pet(cat)': cannot convert argument 1 from 'int' to 'cat'\r\n    pet(0); \/\/oh no\r\n    ^\r\n&lt;source&gt;(16,9): note: No constructor could take the source type, or constructor overload resolution was ambiguous\r\n    pet(0); \/\/oh no\r\n        ^\r\n&lt;source&gt;(13,6): note: or 'void pet(T)'\r\nvoid pet(T);\r\n     ^\r\n&lt;source&gt;(16,5): note: the associated constraints are not satisfied\r\n    pet(0); \/\/oh no\r\n    ^\r\n&lt;source&gt;(12,11): note: the concept 'has_member_pettable&lt;int&gt;' evaluated to false\r\ntemplate &lt;has_member_pettable T&gt;\r\n          ^\r\n&lt;source&gt;(9,48): note: the expression is invalid\r\nconcept has_member_pettable = requires (T t) { t.pet(); };\r\n                                               ^\r\n&lt;source&gt;(16,5): note: while trying to match the argument list '(int)'\r\n    pet(0); \/\/oh no\r\n    ^<\/pre>\n<p>Here is a <a href=\"https:\/\/godbolt.org\/z\/a85z9d5qd\">Compiler Explorer link<\/a> to see the difference.<\/p>\n<p>As part of this work, we\u2019ve also added experimental support for outputting compiler diagnostics as <a href=\"https:\/\/sarifweb.azurewebsites.net\/\">SARIF<\/a>. This is accessible with the experimental flag \/experimental:log&lt;directory&gt;.<\/p>\n<p>In addition to improved diagnostics, we\u2019ve expanded the compiler\u2019s Named Return Value Optimization (NRVO) capabilities. See Bran Hagger\u2019s blog post <a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/improving-copy-and-move-elision\/\">Improving Copy and Move Elision<\/a> for details. The main improvements are in enabling NRVO for cases which involve exception handling or loops. For example, in 17.3, the copy\/move of result when returning it would not be elided, but now will be.<\/p>\n<pre class=\"prettyprint language-cpp\"><code class=\"language-cpp\">Foo ReturnInALoop(int iterations) {\r\n\u00a0 \u00a0 for (int i = 0; i &lt; iterations; ++i) {\r\n\u00a0 \u00a0 \u00a0 \u00a0 Foo result;\r\n\u00a0 \u00a0 \u00a0 \u00a0 if (i == (iterations \/ 2)) {\r\n\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 return result; \/\/copy\/move elided\r\n\u00a0 \u00a0 \u00a0 \u00a0 }\r\n\u00a0 \u00a0 }\r\n}<\/code><\/pre>\n<p>You can see the difference in generated assembly at <a href=\"https:\/\/godbolt.org\/z\/jrP4jcz3G\">this Compiler Explorer link<\/a>.<\/p>\n<h2>CMake &amp; Cross Platform<\/h2>\n<p>Containers are a great way to package up everything for running an application. Through a Dockerfile, all prerequisites are captured so that there is a consistent runtime environment anywhere the container is deployed and run. Dev Containers expand this concept to capture everything necessary for developing and building an application in the container. You can now use Dev Containers for your C++ projects in Visual Studio. You can learn more about this feature in our\u00a0<a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/dev-containers-for-c-in-visual-studio\/\" target=\"_blank\" rel=\"noopener\">Dev Containers for C++ blog post<\/a>.<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-31268\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2022\/11\/word-image-31267-1.png\" alt=\"Alert box saying &quot;Folder contains a dev container configuration file&quot; Options are &quot;Reopen folder in container&quot;, &quot;Settings&quot;, and &quot;Learn more&quot;\" width=\"744\" height=\"40\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2022\/11\/word-image-31267-1.png 744w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2022\/11\/word-image-31267-1-300x16.png 300w\" sizes=\"(max-width: 744px) 100vw, 744px\" \/><\/p>\n<p>Connecting to remote systems with the\u00a0<a href=\"https:\/\/learn.microsoft.com\/en-us\/cpp\/linux\/connect-to-your-remote-linux-computer?view=msvc-170\" target=\"_blank\" rel=\"noopener\">Connection Manager<\/a>\u00a0now supports SSH ProxyJump, which is used to access a SSH host via another SSH host (for example, to access a host behind a firewall).<\/p>\n<p>Test Explorer used to expose internal prefixes of CTest tests, making the list harder to read and navigate. We\u2019ve improved this, grouping all of them under a single header. Here is the before and after:<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-31269\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2022\/11\/word-image-31267-2.png\" alt=\"List from test explorer showing the weird prefixes \" width=\"251\" height=\"201\" \/> <img decoding=\"async\" class=\"alignnone wp-image-31270\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2022\/11\/word-image-31267-3.png\" alt=\"Cleaner list under a ctest header\" width=\"170\" height=\"124\" \/><\/p>\n<h2>Bundled tools<\/h2>\n<p>We made several updates to the additional tools which are shipped with Visual Studio in some workloads.<\/p>\n<p>If you\u2019re using Visual Studio on Arm64 machines, you will now get Arm64 builds of CMake and Ninja through the CMake components in the Visual Studio installer.<\/p>\n<p>We\u2019ve updated the version of CMake which we ship to version 3.24.1. This release comes with many new features, including a &#8211;fresh CLI flag for removing the CMake cache, path comparison in if expressions, and version 5 of CMakePresets.json. We\u2019ll be adding support for CMakePresets.json version 5 in our 17.5 release of Visual Studio 2022, but 17.4 comes with added support for version 4. See the <a href=\"https:\/\/cmake.org\/cmake\/help\/latest\/release\/3.24.html\">CMake release notes<\/a> for all the new goodies.<\/p>\n<p>We also updated the version of LLVM which we ship to version 15.0.1. See the\u00a0<a href=\"https:\/\/releases.llvm.org\/15.0.0\/docs\/ReleaseNotes.html\" target=\"_blank\" rel=\"noopener\">LLVM<\/a>\u00a0and\u00a0<a href=\"https:\/\/releases.llvm.org\/15.0.0\/tools\/clang\/docs\/ReleaseNotes.html\" target=\"_blank\" rel=\"noopener\">Clang<\/a>\u00a0release notes for what is available.<\/p>\n<h2>Productivity<\/h2>\n<p>When using the \u201cCreate Declaration\/Definition\u201d feature, it used to be that the new code would open up in a small window to give you a \u201cpeek\u201d. This is now configurable: you can select between peeking (the default), or opening the document,, or no navigation. The setting is under Options &gt; Text Editor &gt; C\/C++ &gt; Advanced &gt; Refactoring.<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-31271\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2022\/11\/word-image-31267-4.png\" alt=\"Options pane showing &quot;None&quot;, &quot;Peek document&quot;, and &quot;Open document&quot; as the options for the setting &quot;Navigation after create declaration\/definition&quot;\" width=\"749\" height=\"161\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2022\/11\/word-image-31267-4.png 749w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2022\/11\/word-image-31267-4-300x64.png 300w\" sizes=\"(max-width: 749px) 100vw, 749px\" \/><\/p>\n<p>We fixed a consistency gap between IntelliSense and MSBuild for pre-compiled headers. It used to be that, when a PCH was used via\u00a0\/Yu\u00a0and force-included via\u00a0\/FI, IntelliSense would always process it first, before any other headers included via\u00a0\/FI. This did not match the build behavior, so with this change\u00a0\/FI\u00a0headers are processed in the order they are specified.<\/p>\n<h2>IDE Performance<\/h2>\n<p>We are also continuing to improve the performance of the IDE. In this release, we improved indexing performance when opening a new solution. Large projects could see a 20-35% improvement from 17.3. Read more in Victor Ciura&#8217;s blog post, <a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/faster-cpp-source-code-indexing\/\">Visual Studio 2022 Performance: Faster C++ Source Code Indexing<\/a>.<\/p>\n<h2>Code Safety<\/h2>\n<p>We enrich some of our code analysis warnings with \u201ckey events\u201d information which describes how the result of the analysis was arrived at. We improved and expanded this feature by adding this information to more analyses and giving you new ways to visualize it in Visual Studio.<\/p>\n<p>For example, when the <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=WDGIS.MicrosoftSarifViewer\">SARIF Viewer extension<\/a> is installed, the key event information will now be used to annotate the source directly.<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-31272\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2022\/11\/word-image-31267-5.png\" alt=\"Code annotated with reasoning behind an initialization code analysis warning\" width=\"920\" height=\"199\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2022\/11\/word-image-31267-5.png 920w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2022\/11\/word-image-31267-5-300x65.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2022\/11\/word-image-31267-5-768x166.png 768w\" sizes=\"(max-width: 920px) 100vw, 920px\" \/><\/p>\n<p>See the <a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/microsoft-cpp-code-analysis-warnings-with-key-events\/\">Microsoft C++ Code Analysis Warnings with Key Events <\/a>blog post for all the details.<\/p>\n<h2>Conformance<\/h2>\n<p>We\u2019re continuing to track the latest developments in C++ standardization. You can see the latest and upcoming STL features in our <a href=\"https:\/\/github.com\/microsoft\/STL\/wiki\/Changelog\">Changelog on GitHub<\/a>, but here are some of the ones I\u2019m most excited about:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.open-std.org\/jtc1\/sc22\/wg21\/docs\/papers\/2020\/p0881r7.html\" target=\"_blank\" rel=\"noopener\">P0881R7<\/a>\u00a0\u00a0&lt;stacktrace&gt;<\/li>\n<li><a href=\"https:\/\/www.open-std.org\/jtc1\/sc22\/wg21\/docs\/papers\/2021\/p1328r1.html\" target=\"_blank\" rel=\"noopener\">P1328R1<\/a>\u00a0\u00a0constexpr type_info::operator==()<\/li>\n<li><a href=\"https:\/\/www.open-std.org\/jtc1\/sc22\/wg21\/docs\/papers\/2021\/p2440r1.html\" target=\"_blank\" rel=\"noopener\">P2440R1<\/a>\u00a0\u00a0ranges::iota,\u00a0ranges::shift_left,\u00a0ranges::shift_right<\/li>\n<li><a href=\"https:\/\/www.open-std.org\/jtc1\/sc22\/wg21\/docs\/papers\/2022\/p2441r2.html\" target=\"_blank\" rel=\"noopener\">P2441R2<\/a>\u00a0\u00a0views::join_with<\/li>\n<li><a href=\"https:\/\/www.open-std.org\/jtc1\/sc22\/wg21\/docs\/papers\/2022\/p2302r4.html\">P2302R4<\/a>\u00a0 ranges::contains, ranges::contains_subrange<\/li>\n<li style=\"list-style-type: none;\"><\/li>\n<\/ul>\n<p>Conformance work also extends to IntelliSense, which now has support for C23 attributes, and we are continuing to improve the support for C++20 modules.<\/p>\n<h2>vcpkg<\/h2>\n<p>vcpkg is now 6 years old and has over 2000 open-source libraries available!<\/p>\n<p>We\u2019re continuing to add new features both to vcpkg itself, and to Visual Studio to improve integration. For example, vcpkg artifacts is a feature which allows you to describe the tools and environment necessary to build your application. We have now added support to Visual Studio for vcpkg artifacts with CMake projects, such that if your project includes a vcpkg manifest, the environment will be activated automatically on project open. You can learn more about this in the\u00a0<a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/vcpkg-environment-activation-in-visual-studio\/\">vcpkg environment activation in Visual Studio blog post<\/a>.<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-31273\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2022\/11\/text-description-automatically-generated.png\" alt=\"Popup saying &quot;vcpkg environment activation. vcpkg activated successfully. C\/C++ development actions will now run in the vcpkg environment.&quot;\" width=\"383\" height=\"202\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2022\/11\/text-description-automatically-generated.png 383w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2022\/11\/text-description-automatically-generated-300x158.png 300w\" sizes=\"(max-width: 383px) 100vw, 383px\" \/><\/p>\n<p>Other notable improvements since the last release are making the \u201cname\u201d and \u201cversion\u201d fields in vcpkg.json optional, adding schemata for all vcpkg json formats, and improving cross-compilation for macOS. You can read more details about these and more in our monthly blog posts from <a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/vcpkg-august-2022-release-is-now-available-cmake-version-update-updated-faq-cross-compilation-fix-for-apple-silicon\/\">August<\/a> and <a href=\"https:\/\/devblogs.microsoft.com\/cppblog\/vcpkg-september-2022-release-is-now-available-celebrating-6-years-with-over-2000-libraries\/\">September<\/a>.<\/p>\n<h2>Game Development<\/h2>\n<p>We\u2019re working hard on the Unreal Engine integration into Visual Studio. As of 17.4, you can now see which Unreal Engine Blueprints reference, use, and inherit from C++ classes, directly in the IDE. To enable this feature, ensure that the \u201cIDE support for Unreal Engine\u201d component is enabled in the VS Installer, and download <a href=\"https:\/\/www.unrealengine.com\/marketplace\/en-US\/product\/362651520df94e4fa65492dbcba44ae2\">the Visual Studio Integration Tool<\/a> from the Unreal Marketplace.<\/p>\n<p><img decoding=\"async\" class=\"alignnone wp-image-31274\" src=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2022\/11\/word-image-31267-7.png\" alt=\"Popup showing the references to a given blueprint\" width=\"837\" height=\"271\" srcset=\"https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2022\/11\/word-image-31267-7.png 837w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2022\/11\/word-image-31267-7-300x97.png 300w, https:\/\/devblogs.microsoft.com\/cppblog\/wp-content\/uploads\/sites\/9\/2022\/11\/word-image-31267-7-768x249.png 768w\" sizes=\"(max-width: 837px) 100vw, 837px\" \/><\/p>\n<p>Keep an eye out for more new features in 17.5, and please let us know what you think of the Blueprints integration!<\/p>\n<h2>Send us your feedback<\/h2>\n<p>We are very much interested in your feedback to continue to improve this experience. The comments below are open. Feedback can also be shared through the\u00a0<a href=\"https:\/\/developercommunity.visualstudio.com\/cpp\">Developer Community<\/a>. You can also reach us on Twitter (<a href=\"https:\/\/twitter.com\/visualc\">@VisualC<\/a>), or via email at\u00a0<a href=\"mailto:visualcpp@microsoft.com\">visualcpp@microsoft.com<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We are happy to announce that Visual Studio 2022 version 17.4 is now generally available! This post summarizes the new features you can find in this release for C++. You can download Visual Studio 2022 from the Visual Studio downloads page or upgrade your existing installation by following the Update Visual Studio Learn page. Arm64 [&hellip;]<\/p>\n","protected":false},"author":706,"featured_media":31272,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[270,1],"tags":[],"class_list":["post-31267","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-announcement","category-cplusplus"],"acf":[],"blog_post_summary":"<p>We are happy to announce that Visual Studio 2022 version 17.4 is now generally available! This post summarizes the new features you can find in this release for C++. You can download Visual Studio 2022 from the Visual Studio downloads page or upgrade your existing installation by following the Update Visual Studio Learn page. Arm64 [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/31267","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\/706"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=31267"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/31267\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media\/31272"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media?parent=31267"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=31267"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=31267"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}