What’s New for C++ Developers in Visual Studio 2022 17.8

Sy Brand

We are happy to announce that Visual Studio 2022 version 17.8 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.

Standard Library

The Standard Library Modules standardized in C++23 are now available in C++20 mode. This is a cross-vendor extension, planned or supported also by libstdc++ and libc++.

We have also implemented several new C++23 and C++26 features, including augmented support for Freestanding implementations and support for std::stacktrace in std::format. Read all the details in the STL Changelog.

Core Editor

Create a Pull Request

You can now create a Pull Request directly in Visual Studio. Enter the New Pull Request window by clicking the link in the notification banner in Git Changes after pushing, or from the top-level menu via Git > GitHub/Azure DevOps > New Pull Request.

A screenshot of a computer Description automatically generated

Summary Diff

Leverage the new summary difference view to focus on the changes in your code.

A screenshot of a computer Description automatically generated

Enabled in every comparison view, the new summary difference view allows you to toggle the context lines to do file comparison faster.

Productivity

Structured Diagnostics

Massive compiler errors which seem impossible to navigate are the bane of many C++ developers’ lives. It’s up to tools to provide a better experience to help you comprehend diagnostics and understand how to fix the root issue.

To aid this, you can now view structured diagnostics in the Output window and new Problem Details window. Error List entries which have additional information available will show an icon in the new Details column.

A screenshot of a computer screen Description automatically generated

Clicking this will open these details in the Problem Details window, allowing you to navigate through the associated information of the error:

A screenshot of a computer Description automatically generated

This nested structure is also reflected in the Output window:

1>Source.cpp(18,6):  
1>or 'void pet(_T0)'  
1>Source.cpp(23,5):  
1>the associated constraints are not satisfied  
1>	Source.cpp(18,10):  
1>	the concept 'pettable<lizard>' evaluated to false  
1>		Source.cpp(16,20):  
1>		the concept 'has_member_pet<lizard>' evaluated to false  
1>			Source.cpp(10,44):  
1>			'pet': is not a member of 'lizard'  
1>			Source.cpp(20,8):  
1>			see declaration of 'lizard'  
1>		Source.cpp(16,41):  
1>		the concept 'has_default_pet<lizard>' evaluated to false  
1>			Source.cpp(13,30):  
1>			'is_pettable': is not a member of 'lizard'  
1>			Source.cpp(20,8):  
1>			see declaration of 'lizard' 

Find out more about this feature at Structured Diagnostics in the New Problem Details Window.

Size and Alignment of Classes, Structs, and Unions

Based on feedback from you, we have introduced a Size and Alignment feature. This feature enables you to visualize the size and alignment of your classes, structs, unions, base types, or enums even before the code is compiled. To check the size and alignment, hover over the identifier and a Quick Info tooltip will display the information.

A screenshot of a computer Description automatically generated

Make Member Function Const

We have introduced a feature that suggests that you make member functions const when they don’t modify the object’s state. You can hover over a member function and click the light bulb icon to quickly access the suggestion and mark the function as const.

A screenshot of a computer program Description automatically generated

This feature is enabled by default as a suggestion. You can configure its settings by navigating to Tools > Options > Text Editor > C/C++ > Code Style > Linter.

A screenshot of a computer Description automatically generated

Make Global Function Static

Visual Studio now prompts you to mark global functions as static. When you encounter a global function lacking a forward declaration, Visual Studio will provide a suggestion, symbolized by a screwdriver icon.

A computer screen with text and numbers Description automatically generated

You can adjust the settings for this feature under Tools > Options > Text Editor > C/C++ > IntelliSense. To learn more about this feature and Make Member Function Const, check out our Make Member Function const and Global Function Static in Visual Studio Blog.

Clean Up and Sort #include Directives

You can now sort and clean up your #include directives automatically.

Unused #include directives will be dimmed in the editor. You can hover over a dimmed include and use the lightbulb menu to either remove that include or all unused includes.

A screen shot of a computer screen Description automatically generated

There is now also the option to add #include directives for entities which are currently indirectly included via other headers. For example, if you use std::string in your code but don’t #include <string>, the code will still work if some other header you include transitively includes the correct header. This makes the code fragile to changes in other headers. If #include cleanup detects indirect headers, a quick action (indicated by three dots in the default view) will appear. Hovering over it will inform you that content from that transitive include is being used. Then, you have the option to either add the direct include individually or add all transitively used includes.

A computer screen with text and images Description automatically generated

Find out more about this feature at Clean up C/C++ #includes in Visual Studio.

To automatically sort #includes, right-click on any #include statement. Then, hovering over the #include directives option in the context menu will reveal “Sort #include directives.”

A screenshot of a computer Description automatically generated

You can also configure transitive include cleanups and include sorting through the Code Cleanup entry. First, open the Code Cleanup configuration menu through Analyze > Code Cleanup > Configure Code Cleanup, or by clicking the arrow next to the broom icon in the bottom status bar and selecting Configure Code Cleanup. Add the desired features to the Included fixers section, then click the broom icon to run them.

A screenshot of a computer Description automatically generated

You can configure include cleanup and sorting at Tools > Options > Text Editor > C/C++ > Code Cleanup.

A screenshot of a computer program Description automatically generated

Game Development

Unreal Engine Test Adapter

Special thanks to the folks at Rare who contributed tremendously to this feature.

Streamline your testing process without leaving the IDE with Unreal Engine Test Adapter. You can now discover, run, manage, and debug your Unreal Engine tests. In Visual Studio 2022 version 17.8, your Unreal Engine tests will automatically show up when you open Visual Studio. To see your tests, you can open Test Explorer with View > Test Explorer.

A screenshot of a computer Description automatically generated

The latest version of our free Visual Studio Tools for Unreal Engine is required to use Unreal Engine Test Adapter. In addition, ensure the “Unreal Engine Test Adapter” component in the “Game development with C++” workload is enabled in the Visual Studio Installer.

Unreal Engine Code Snippets

Write code more efficiently with Unreal Engine Code Snippets. In Visual Studio 2022 version 17.8, you can find common Unreal Engine constructs as snippets in your member list. To get started, type any Unreal Engine construct name, for example uclass. Press Tab or Enter to expand the snippet.

A computer screen shot of a program code Description automatically generated

We have also included exported versions of UCLASS (uclass, uclassexported), UINTERFACE (uinterface, uinterfaceexported), and USTRUCT (ustruct, ustructexported) for those working with exported APIs and plugins. In addition, we have included macros such as SWidget (swidget), TActorRange (tactorrange), TObjectRange (tobjectrange), and WITH_EDITOR (witheditor) based on your feedback.

List of Supported Snippets

  • uclass
  • uclassexported
  • uenum
  • ufunction
  • uinterface
  • uinterfaceexported
  • uproperty
  • ustruct
  • ustructexported
  • uelog
  • swidget
  • tactorrange
  • tobjectrange
  • witheditor

Unreal Engine Macro Specifier Suggestions

This is currently an experimental feature and will be gradually made available to Unreal Engine developers in the coming weeks.

One of the top feedback items we commonly receive is suggesting Unreal Engine macro specifiers. We are happy to share that macro specifiers will start appearing in your member list suggestions for reflection macros in Visual Studio 2022 version 17.8. This feature will help you quickly access all possible specifiers for respective macros without relying on memory or switching back and forth between Visual Studio and documentation.

A screenshot of a computer program Description automatically generated

Build Insights Functions View

Build Insights is now integrated with Visual Studio 2022 and works with MSBuild and CMake projects using MSVC. In Visual Studio 2022 version 17.8, you can now see additional information relating to function generation. The new Functions View will provide you with how long a function takes during compilation as well as the number of ForceInlines associated.

A screenshot of a program Description automatically generated

Start your Build Insights .etl trace capture by going to the Build Menu.

After compilation, Build Insights will create a diagnostic report that shows you function generation time as well as ForceInlines.

Cross Platform

Remote Linux Unit Test Support

We have added support so that you can run CTest and GTest tests on your remote Linux machines from Visual Studio’s Test Explorer, just like you would any local tests.

CMake Targets View Improvements

To make the CMake Targets View more usable, we have implemented a few new improvements to make it easier than ever to navigate your CMake targets. This includes improved navigation to the CMake Targets View, a new, more simplified CMake Targets View, and the ability to exclude specified CMake items from the Targets View.

Now, you can right-click anywhere in your Solution Explorer and simply navigate to the CMake Targets View from the context menu.

A screenshot of a computer Description automatically generated

The CMake Targets View has been further simplified so that users don’t have to click through folders without buildable executables to get to their desired target.

A screenshot of a computer program Description automatically generated

You can also now define in your VSWorkspaceSettings.json items to exclude from the CMake Targets View using the new CMakeTargetsViewExcludedItems field, which is an array of strings.

To view more details, please see this blog post: Enhancing the CMake Targets View in Visual Studio.

Send us your feedback

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 Visual Studio Developer Community. You can also reach us on Twitter (@VisualC), or via email at visualcpp@microsoft.com.

15 comments

Discussion is closed. Login to edit/delete existing comments.

  • Roger B 2

    *Sigh* The compiler team is still MIA for their side of c++23 support… And they’re blocking the Library team from completing things like “constexpr for cmath and cstdlib”

    I hope they’re at least working on something useful, like getting to performance parity with GCC/Clang on basic stuff.

    • Hristo Hristov 0

      They were supposed to have been working on C++20 modules 🙂
      I don’t see much improvement yet though.

    • Hristo Hristov 1

      I used this option in VSCode and it created more noise then resolved problems. It should be used very carefully. I’ve seen it adding internal libc++ headers 🙂 and any other weird stuff and I think VSCode shares this code with VS2022.

    • André Köhler 1

      I have the same issue. The options do not exist and the unused #include directives are not detected.

    • Mryam GirmayMicrosoft employee 1

      We are gradually rolling out this feature in Visual Studio 2022 version 17.8 to monitor some data. This means that not everyone will have access to the feature immediately after its release.

      • Jordi Molist 0

        Is there some prevision about when we will see available this option?

        • Mryam GirmayMicrosoft employee 1

          It’s incrementally rolling out over the next few weeks.

  • Hristo Hristov 0

    > The Standard Library Modules standardized in C++23 are now available in C++20 mode. This is a cross-vendor extension, planned or supported also by libstdc++ and libc++.

    When will CMake/Ninja support happen? My understanding is that the modules need to be built for each project and this needs to happen automatically for the best user experience.

  • Paulo Pinto 1

    Regarding “The Standard Library Modules standardized in C++23 are now available in C++20 mode.”, this is definitly not the case in VS 17.8.0.

    I was greeted with tons of missing symbols errors, with repeated occurrences of

    1>C:\Projects\private\RaytracingWeekend-CPP\OneWeekend\Raytracing\predefined C++ types (compiler internal)(348,11):
    1>see declaration of 'std'

    Enabling the option to always compile C++23 standard library had no effect.

      • Paulo Pinto 1

        Ah no Visual Studio integration, rather it needs some CLI help. Thanks

        EDIT: After having a go at it, I was faced with incompatible versions, and decided not to waste any more time trying to make it work.

        IFC file "C:\....\std\std.ifc" has unsupported version 0.43

        Even if /std:c++20 is used when building the std.

      • Victor Derks 1

        Some more information how to integrate this in a .vcxproj file would be helpful (best practice).

        There is the project configuration property “Build ISO C++23 Standard Library Module”. This option works out-of-the-box, but only for /stdC++-latest.

  • Frank Munkert 0

    Does the new Structured Diagnostics feature also work with CMake projects? If yes, what steps are necessary to enable it?
    Currently, concept/template-related errors in my CMake projects generate the same unstructured output as in previous VS versions.

    • Sy BrandMicrosoft employee 0

      Not yet, it’s on our roadmap!

Feedback usabilla icon