Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
56ce423
Improve C++20 modules support
sylveon Jun 2, 2021
3430aad
IAsyncOperation started working, so enable it back
sylveon Jul 31, 2021
e824d4d
Merge branch 'master' into user/sjones/modules
Scottj1s Dec 9, 2021
ac0b44d
merge fixes, workaround
Scottj1s Dec 9, 2021
ce85a5a
Merge branch 'master' into user/sjones/modules
sylveon May 27, 2022
5b41ed8
Remove workarounds for now fixed issues
sylveon May 27, 2022
f233743
Switch to using /std:c++20 for test_cpp20
sylveon May 27, 2022
855072d
Fix include in purview of a module
sylveon May 31, 2022
42b1984
[WIP] Modular C++20 module support
sylveon Aug 24, 2022
494ac8f
Remove experimental coroutines support
sylveon Nov 6, 2025
b8d5690
Fix clang-cl mismatching signedness error
sylveon Nov 6, 2025
6c2773b
Merge branch 'master' into user/sylveon/await
DefaultRyan Mar 13, 2026
de710f1
Require coroutine support for C++/WinRT
DefaultRyan Mar 13, 2026
5fd5dd6
Merge branch 'master' of https://github.com/microsoft/cppwinrt into u…
sylveon Mar 14, 2026
a3791af
Merge branch 'user/sylveon/await' of https://github.com/sylveon/cppwi…
sylveon Mar 15, 2026
fefb00a
WIP
sylveon Mar 15, 2026
45ed914
Fixes
sylveon Mar 15, 2026
6f7cd5f
Merge branch 'master' of https://github.com/microsoft/cppwinrt into u…
sylveon Mar 16, 2026
c014429
Avoid std includes in base.h when built as a module
sylveon Mar 16, 2026
fd81ad4
Restore version check functionality in modules mode
sylveon Mar 16, 2026
a5fe8aa
Fix version check under classic compilation
sylveon Mar 16, 2026
ba71dcc
Merge branch 'master' of https://github.com/microsoft/cppwinrt into u…
sylveon Mar 18, 2026
b7c9076
Add extern C++ to function pointer overrides to allow interop between…
sylveon Mar 18, 2026
3a5d23c
Also export them
sylveon Mar 18, 2026
97926f2
byte -> std::uint8_t
sylveon Mar 18, 2026
1b3c64c
Add #include <cstddeef> in base_version
sylveon Mar 21, 2026
136cb3b
Merge branch 'master' of https://github.com/microsoft/cppwinrt into u…
sylveon Mar 21, 2026
a618059
Fix integer fields causing impl promotion
sylveon Mar 21, 2026
18157da
Merge branch 'master' of https://github.com/microsoft/cppwinrt into u…
sylveon Mar 24, 2026
bece4d8
Fix natvis build
sylveon Mar 24, 2026
a0d17b6
Avoid non-portable include
sylveon Mar 24, 2026
5858e0a
Workaround compiler issue by hoisting access token guard outside of t…
sylveon Mar 24, 2026
7497739
Add missing inline
sylveon Mar 24, 2026
33d9011
Add dedicated modules tests
sylveon Mar 24, 2026
c80a12e
Bump CMake in test_cppmodules to 3.28 (required for modules)
sylveon Mar 24, 2026
09f386d
Remove TODO
sylveon Mar 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ jobs:
compiler: [MSVC, clang-cl]
arch: [x86, x64, arm64]
config: [Debug, Release]
test_exe: [test, test_nocoro, test_cpp20, test_cpp20_no_sourcelocation, test_fast, test_slow, test_old, test_module_lock_custom, test_module_lock_none]
test_exe: [test, test_nocoro, test_cppmodules test_cpp20, test_cpp20_no_sourcelocation, test_fast, test_slow, test_old, test_module_lock_custom, test_module_lock_none]
exclude:
- arch: arm64
config: Debug
Expand Down
4 changes: 4 additions & 0 deletions .pipelines/jobs/OneBranchTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ jobs:
TestExe: 'test_nocoro'
TestProject: 'test_nocoro'
BuildPlatform: 'x86'
test_cppmodules.x86:
TestExe: 'test_cppmodules'
TestProject: 'test_cppmodules'
BuildPlatform: 'x86'
test_cpp20.x86:
TestExe: 'test_cpp20'
TestProject: 'test_cpp20'
Expand Down
3 changes: 2 additions & 1 deletion Directory.Build.Props
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@
<TreatWarningAsError>true</TreatWarningAsError>
<SDLCheck>true</SDLCheck>
<ConformanceMode>true</ConformanceMode>
<LanguageStandard Condition="'$(CppWinRTLanguageStandard)'==''">stdcpp17</LanguageStandard>
<LanguageStandard Condition="'$(CppWinRTLanguageStandard)'=='' Or '$(CppWinRTLanguageStandard)'=='17'">stdcpp17</LanguageStandard>
<LanguageStandard Condition="'$(CppWinRTLanguageStandard)'=='20'">stdcpp20</LanguageStandard>
<LanguageStandard Condition="'$(CppWinRTLanguageStandard)'=='latest'">stdcpplatest</LanguageStandard>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<PreprocessorDefinitions>CPPWINRT_VERSION_STRING="$(CppWinRTBuildVersion)";%(PreprocessorDefinitions)</PreprocessorDefinitions>
Expand Down
1 change: 1 addition & 0 deletions build_test_all.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ call msbuild /p:Configuration=%target_configuration%,Platform=%target_platform%,

call msbuild /m /p:Configuration=%target_configuration%,Platform=%target_platform%,CppWinRTBuildVersion=%target_version% cppwinrt.sln /t:test\test
call msbuild /m /p:Configuration=%target_configuration%,Platform=%target_platform%,CppWinRTBuildVersion=%target_version% cppwinrt.sln /t:test\test_nocoro
call msbuild /m /p:Configuration=%target_configuration%,Platform=%target_platform%,CppWinRTBuildVersion=%target_version% cppwinrt.sln /t:test\test_cppmodules
call msbuild /m /p:Configuration=%target_configuration%,Platform=%target_platform%,CppWinRTBuildVersion=%target_version% cppwinrt.sln /t:test\test_cpp20
call msbuild /m /p:Configuration=%target_configuration%,Platform=%target_platform%,CppWinRTBuildVersion=%target_version% cppwinrt.sln /t:test\test_cpp20_no_sourcelocation
call msbuild /m /p:Configuration=%target_configuration%,Platform=%target_platform%,CppWinRTBuildVersion=%target_version% cppwinrt.sln /t:test\test_fast
Expand Down
19 changes: 19 additions & 0 deletions cppwinrt.sln
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_nocoro", "test\test_no
{D613FB39-5035-4043-91E2-BAB323908AF4} = {D613FB39-5035-4043-91E2-BAB323908AF4}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test_cppmodules", "test\test_cppmodules\test_cppmodules.vcxproj", "{4A135922-BE13-4FEC-8280-69028D1CB28D}"
ProjectSection(ProjectDependencies) = postProject
{A91B8BF3-28E4-4D9E-8DBA-64B70E4F0270} = {A91B8BF3-28E4-4D9E-8DBA-64B70E4F0270}
{D613FB39-5035-4043-91E2-BAB323908AF4} = {D613FB39-5035-4043-91E2-BAB323908AF4}
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D15C8430-A7CD-4616-BD84-243B26A9F1C2}"
ProjectSection(SolutionItems) = preProject
build_nuget.cmd = build_nuget.cmd
Expand Down Expand Up @@ -411,6 +417,18 @@ Global
{9E392830-805A-4AAF-932D-C493143EFACA}.Release|x64.Build.0 = Release|x64
{9E392830-805A-4AAF-932D-C493143EFACA}.Release|x86.ActiveCfg = Release|Win32
{9E392830-805A-4AAF-932D-C493143EFACA}.Release|x86.Build.0 = Release|Win32
{4A135922-BE13-4FEC-8280-69028D1CB28D}.Debug|ARM64.ActiveCfg = Debug|ARM64
{4A135922-BE13-4FEC-8280-69028D1CB28D}.Debug|ARM64.Build.0 = Debug|ARM64
{4A135922-BE13-4FEC-8280-69028D1CB28D}.Debug|x64.ActiveCfg = Debug|x64
{4A135922-BE13-4FEC-8280-69028D1CB28D}.Debug|x64.Build.0 = Debug|x64
{4A135922-BE13-4FEC-8280-69028D1CB28D}.Debug|x86.ActiveCfg = Debug|Win32
{4A135922-BE13-4FEC-8280-69028D1CB28D}.Debug|x86.Build.0 = Debug|Win32
{4A135922-BE13-4FEC-8280-69028D1CB28D}.Release|ARM64.ActiveCfg = Release|ARM64
{4A135922-BE13-4FEC-8280-69028D1CB28D}.Release|ARM64.Build.0 = Release|ARM64
{4A135922-BE13-4FEC-8280-69028D1CB28D}.Release|x64.ActiveCfg = Release|x64
{4A135922-BE13-4FEC-8280-69028D1CB28D}.Release|x64.Build.0 = Release|x64
{4A135922-BE13-4FEC-8280-69028D1CB28D}.Release|x86.ActiveCfg = Release|Win32
{4A135922-BE13-4FEC-8280-69028D1CB28D}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -435,6 +453,7 @@ Global
{5FF6CD6C-515A-4D55-97B6-62AD9BCB77EA} = {3C7EA5F8-6E8C-4376-B499-2CAF596384B0}
{D4C8F881-84D5-4A7B-8BDE-AB4E34A05374} = {3C7EA5F8-6E8C-4376-B499-2CAF596384B0}
{9E392830-805A-4AAF-932D-C493143EFACA} = {3C7EA5F8-6E8C-4376-B499-2CAF596384B0}
{4A135922-BE13-4FEC-8280-69028D1CB28D} = {3C7EA5F8-6E8C-4376-B499-2CAF596384B0}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2783B8FD-EA3B-4D6B-9F81-662D289E02AA}
Expand Down
70 changes: 59 additions & 11 deletions cppwinrt/code_writers.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ namespace cppwinrt

static void write_version_assert(writer& w)
{
w.write_root_include("base");
auto format = R"(static_assert(winrt::check_version(CPPWINRT_VERSION, "%"), "Mismatched C++/WinRT headers.");
#define CPPWINRT_VERSION "%"
)";
Expand Down Expand Up @@ -123,6 +122,16 @@ namespace cppwinrt
return { w, write_endif };
}

[[nodiscard]] static finish_with wrap_ifndef(writer& w, std::string_view macro)
{
auto format = R"(#ifndef %
)";

w.write(format, macro);

return { w, write_endif };
}

static void write_parent_depends(writer& w, cache const& c, std::string_view const& type_namespace)
{
auto pos = type_namespace.rfind('.');
Expand All @@ -145,6 +154,28 @@ namespace cppwinrt
}
}

static void write_parent_imports(writer& w, cache const& c, std::string_view const& type_namespace)
{
auto pos = type_namespace.rfind('.');

if (pos == std::string::npos)
{
return;
}

auto parent = type_namespace.substr(0, pos);
auto found = c.namespaces().find(parent);

if (found != c.namespaces().end() && has_projected_types(found->second))
{
w.write_import(parent);
}
else
{
write_parent_imports(w, c, parent);
}
}

static void write_pch(writer& w)
{
auto format = R"(#include "%"
Expand Down Expand Up @@ -313,11 +344,22 @@ namespace cppwinrt
return;
}

if (type_name == "Windows.Foundation.DateTime" ||
type_name == "Windows.Foundation.TimeSpan")
if (type_name.name_space == "Windows.Foundation")
{
// Don't forward declare these since they're not structs.
return;
if (type_name.name == "DateTime" ||
type_name.name == "TimeSpan")
{
// Don't forward declare these since they're not structs.
return;
}

if (type_name.name == "Point" ||
type_name.name == "Rect" ||
type_name.name == "Size")
{
// Don't forward declare these since they're already defined in base.h.
return;
}
}

if (type_name.name_space == "Windows.Foundation.Numerics")
Expand Down Expand Up @@ -2812,8 +2854,15 @@ struct WINRT_IMPL_EMPTY_BASES produce_dispatch_to_overridable<T, D, %>
}
}

static bool write_structs(writer& w, std::vector<TypeDef> const& types)
struct write_structs_result
{
bool promote = false;
};

static write_structs_result write_structs(writer& w, std::vector<TypeDef> const& types)
{
write_structs_result result{};

auto format = R"( struct %
{
% };
Expand All @@ -2829,7 +2878,7 @@ struct WINRT_IMPL_EMPTY_BASES produce_dispatch_to_overridable<T, D, %>

if (types.empty())
{
return false;
return result;
}

struct complex_struct
Expand Down Expand Up @@ -2895,7 +2944,6 @@ struct WINRT_IMPL_EMPTY_BASES produce_dispatch_to_overridable<T, D, %>
}
}

bool promote = false;
auto cpp_namespace = w.write_temp("@", w.type_namespace);

for (auto&& type : structs)
Expand All @@ -2921,14 +2969,14 @@ struct WINRT_IMPL_EMPTY_BASES produce_dispatch_to_overridable<T, D, %>
continue;
}

if (!starts_with(field.second, cpp_namespace))
if (!result.promote && !starts_with(field.second, cpp_namespace))
{
promote = true;
result.promote = true;
}
}
}

return promote;
return result;
}

static void write_class_requires(writer& w, TypeDef const& type)
Expand Down
6 changes: 4 additions & 2 deletions cppwinrt/cppwinrt.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
<ClInclude Include="..\strings\base_com_ptr.h" />
<ClInclude Include="..\strings\base_coroutine_foundation.h" />
<ClInclude Include="..\strings\base_coroutine_system.h" />
<ClInclude Include="..\strings\base_coroutine_system_winui.h" />
<ClInclude Include="..\strings\base_coroutine_threadpool.h" />
<ClInclude Include="..\strings\base_coroutine_ui_core.h" />
<ClInclude Include="..\strings\base_deferral.h" />
Expand All @@ -56,20 +55,23 @@
<ClInclude Include="..\strings\base_extern.h" />
<ClInclude Include="..\strings\base_fast_forward.h" />
<ClInclude Include="..\strings\base_foundation.h" />
<ClInclude Include="..\strings\base_global_fragment.h" />
<ClInclude Include="..\strings\base_handle.h" />
<ClInclude Include="..\strings\base_identity.h" />
<ClInclude Include="..\strings\base_implements.h" />
<ClInclude Include="..\strings\base_includes.h" />
<ClInclude Include="..\strings\base_iterator.h" />
<ClInclude Include="..\strings\base_lock.h" />
<ClInclude Include="..\strings\base_macros.h" />
<ClInclude Include="..\strings\base_marshaler.h" />
<ClInclude Include="..\strings\base_meta.h" />
<ClInclude Include="..\strings\base_natvis.h" />
<ClInclude Include="..\strings\base_numerics.h" />
<ClInclude Include="..\strings\base_reference_produce.h" />
<ClInclude Include="..\strings\base_reference_produce_1.h" />
<ClInclude Include="..\strings\base_security.h" />
<ClInclude Include="..\strings\base_shared.h" />
<ClInclude Include="..\strings\base_std_hash.h" />
<ClInclude Include="..\strings\base_std_includes.h" />
<ClInclude Include="..\strings\base_string.h" />
<ClInclude Include="..\strings\base_stringable_format.h" />
<ClInclude Include="..\strings\base_stringable_streams.h" />
Expand Down
18 changes: 12 additions & 6 deletions cppwinrt/cppwinrt.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,6 @@
<ClInclude Include="cmd_reader.h" />
<ClInclude Include="task_group.h" />
<ClInclude Include="text_writer.h" />
<ClInclude Include="..\strings\base_includes.h">
<Filter>strings</Filter>
</ClInclude>
<ClInclude Include="..\strings\base_iterator.h">
<Filter>strings</Filter>
</ClInclude>
Expand All @@ -178,15 +175,24 @@
<ClInclude Include="..\strings\base_coroutine_system.h">
<Filter>strings</Filter>
</ClInclude>
<ClInclude Include="..\strings\base_coroutine_system_winui.h">
<Filter>strings</Filter>
</ClInclude>
<ClInclude Include="..\strings\base_xaml_component_connector_winui.h">
<Filter>strings</Filter>
</ClInclude>
<ClInclude Include="..\strings\base_stringable_to_hstring.h">
<Filter>strings</Filter>
</ClInclude>
<ClInclude Include="..\strings\base_shared.h">
<Filter>strings</Filter>
</ClInclude>
<ClInclude Include="..\strings\base_global_fragment.h">
<Filter>strings</Filter>
</ClInclude>
<ClInclude Include="..\strings\base_numerics.h">
<Filter>strings</Filter>
</ClInclude>
<ClInclude Include="..\strings\base_std_includes.h">
<Filter>strings</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="$(OutDir)version.rc" />
Expand Down
Loading