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.
Summary Diff
Leverage the new summary difference view to focus on the changes in your code.
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.
Clicking this will open these details in the Problem Details window, allowing you to navigate through the associated information of the error:
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.
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.
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.
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.
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.
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.
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.”
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.
You can configure include cleanup and sorting at Tools > Options > Text Editor > C/C++ > Code Cleanup.
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.
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.
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.
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.
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.
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.
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.
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.
Not yet, it’s on our roadmap!
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
Enabling the option to always compile C++23 standard library had no effect.
You’ll still need to follow the same process for using standard library modules as you would for C++23: https://learn.microsoft.com/en-us/cpp/cpp/tutorial-import-stl-named-module?view=msvc-170
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.
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.
Even if /std:c++20 is used when building the std.
> 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.
Why can’t I see the option to clean the unnecessary includes? In the section of Code clean up I can only find the Sort includes section, but no the Include cleanup section. In the following article you showed this option: https://learn.microsoft.com/es-es/cpp/ide/include-cleanup-config?view=msvc-170#turn-on-include-cleanup
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.
Is there some prevision about when we will see available this option?
It’s incrementally rolling out over the next few weeks.
I have the same issue. The options do not exist and the unused #include directives are not detected.
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.
*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.
They were supposed to have been working on C++20 modules 🙂
I don’t see much improvement yet though.