What’s New for C++ Developers in Visual Studio 2022 17.8
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.
We have also implemented several new C++23 and C++26 features, including augmented support for Freestanding implementations and support for
std::format. Read all the details in the STL Changelog.
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.
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.
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.
#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.
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
ustructexported) for those working with exported APIs and plugins. In addition, we have included macros such as
witheditor) based on your feedback.
List of Supported Snippets
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
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
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 email@example.com.