Skip to content

Build C++ samples with C++20 to fix STL1011, and map VS 2026 to v145 - #657

Merged
Harini Malothu (HariniMalothu17) merged 3 commits into
microsoft:mainfrom
iamAbhi-916:user/abhijeetjha/cppwinrt-cpp20-stl1011
Aug 11, 2026
Merged

Harini Malothu (HariniMalothu17) merged 3 commits into
microsoft:mainfrom
iamAbhi-916:user/abhijeetjha/cppwinrt-cpp20-stl1011

Conversation

@iamAbhi-916

@iamAbhi-916 Abhijeet Jha (iamAbhi-916) commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Description

Fixes the C++ samples failing to build on current toolsets: error STL1011 from the deprecated /await switch, error MSB8020 on Visual Studio 2026, and the template conformance errors in UXFrameworksOnIslands.

Fixes ADO 62276972.

Root cause

STL1011 — Microsoft.Windows.CppWinRT.props defaults ClCompile.LanguageStandard to stdcpp17 when a project does not set one, and Microsoft.Windows.CppWinRT.targets then adds /await for stdcpp17. Under /await, winrt/base.h takes the experimental branch and includes the experimental/coroutine header, which now hard-errors. This hits every C++/WinRT sample, whether or not it uses coroutines.

MSB8020 — Build.Common.Cpp.props has no BuildToolVersion entry for VS 2026, so PlatformToolset is assigned an empty value and MSBuild falls back to v100.

C2061 / C4864 — UXFrameworksOnIslands relies on unqualified lookup finding members of a dependent base, which current MSVC rejects under two-phase lookup.

Fix

Set LanguageStandard to stdcpp20 in Samples/Directory.Build.props, and map BuildToolVersion 18 to v145 in Samples/Build.Common.Cpp.props.

Why 8 files for the language standard: Directory.Build.props is imported before the project body, so the 7 projects that set their own stdcpp17 overwrite it — they would still get /await and still fail STL1011, so they are updated individually. The other 33 set no value of their own, so they inherit it and need no edit.

SampleWidgetProviderApp was the only C++ sample that neither imported Build.Common.Cpp.props nor set its own PlatformToolset, so it now imports the shared props like the other C++ samples.

For UXFrameworksOnIslands: TextVisual<T> derives from D2DSprite<T>, so ContainerVisual, GetVisual, GetBackgroundColor and InvalidateContent are introduced with using-declarations, which also resolves the cascading C2065/C3861/C2672 errors in TextVisual.cpp and in the InsertTextVisual callers. In AutomationFragment::RemoveChild the lambda parameter is dependent, so the member template call needs the template disambiguator. These are pre-existing conformance gaps unrelated to the language standard — they reproduce at stdcpp17 with STL1011 suppressed.

Validation

Built all 41 C++/WinRT sample solutions at x64 Release on Visual Studio 2026 (MSVC 14.51.36231), before and after the change, with no command-line overrides:

Built Failed
main 15 26
this PR 32 9

Runtime: the rebuilt unpackaged console samples launch without crashing and reach the Windows App SDK bootstrapper. A full functional run was not possible on the validation machine because the matching Windows App Runtime is not installed there.

Target Release

1.8

Checklist

Note that /azp run currently isn't working for this repo.

Builds were run at x64 Release; x86/ARM64 and Debug are unverified. The change is a language-standard switch applied uniformly across all configurations, so it is not configuration-specific.

@iamAbhi-916
Abhijeet Jha (iamAbhi-916) force-pushed the user/abhijeetjha/cppwinrt-cpp20-stl1011 branch 5 times, most recently from e996d0a to 8590581 Compare August 11, 2026 06:49
@iamAbhi-916
Abhijeet Jha (iamAbhi-916) marked this pull request as ready for review August 11, 2026 07:00
Comment thread Samples/Directory.Build.props Outdated

<ItemDefinitionGroup>
<ClCompile>
<!-- Microsoft.Windows.CppWinRT.props defaults LanguageStandard to stdcpp17 when a project

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment can be removed i think

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay , will clean it up

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@iamAbhi-916

Copy link
Copy Markdown
Contributor Author

/azp run

<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard>stdcpp20</LanguageStandard>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah it would be better to add this too, will update

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Abhijeet Jha and others added 3 commits August 11, 2026 15:38
Microsoft.Windows.CppWinRT.props defaults ClCompile.LanguageStandard to stdcpp17 when a
project does not set one, and Microsoft.Windows.CppWinRT.targets then adds the deprecated
/await switch for stdcpp17. Under /await, winrt/base.h takes the experimental branch and
includes <experimental/coroutine>, which now hard-errors:

  experimental/coroutine(37): error C2338: static assertion failed:
  'error STL1011: The /await compiler option, <experimental/coroutine>, ... are
  deprecated by Microsoft and will be REMOVED SOON.'

Set the standard in Samples/Directory.Build.props, which already carries the shared
ClCompile item definitions, so it is picked up before the C++/WinRT default applies. The
seven projects that set LanguageStandard in their own project body override that, so they
are updated individually.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
BuildToolVersion 18 had no AutoDetectedPlatformToolset entry, so PlatformToolset was
assigned an empty value and MSBuild fell back to v100:

  Microsoft.CppBuild.targets(473,5): error MSB8020: The build tools for Visual Studio
  2010 (Platform Toolset = 'v100') cannot be found.

SampleWidgetProviderApp was the only C++ sample that neither imported
Build.Common.Cpp.props nor set its own PlatformToolset, so it imports the shared props
now, like the other C++ samples.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The sample relied on unqualified lookup finding members of a dependent base, which
current MSVC rejects under two-phase lookup:

  TextVisual.h(22): error C2061: syntax error: identifier 'ContainerVisual'
  AutomationFragment.cpp(77): warning C4864: expected 'template' keyword before
  dependent template name

TextVisual<T> derives from D2DSprite<T>, so ContainerVisual, GetVisual,
GetBackgroundColor and InvalidateContent are introduced with using-declarations, which
also resolves the cascading C2065/C3861/C2672 errors in TextVisual.cpp and in the
InsertTextVisual callers. In AutomationFragment::RemoveChild the lambda parameter is
dependent, so the member template call needs the template disambiguator.

Both are pre-existing conformance gaps, unrelated to the language standard: they
reproduce at stdcpp17 with STL1011 suppressed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@iamAbhi-916
Abhijeet Jha (iamAbhi-916) force-pushed the user/abhijeetjha/cppwinrt-cpp20-stl1011 branch from a3e1700 to 354a3be Compare August 11, 2026 10:10
@HariniMalothu17
Harini Malothu (HariniMalothu17) merged commit 18431c6 into microsoft:main Aug 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants