Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 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
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
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
69 changes: 58 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,7 +2854,12 @@ 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)
{
auto format = R"( struct %
{
Expand All @@ -2829,7 +2876,7 @@ struct WINRT_IMPL_EMPTY_BASES produce_dispatch_to_overridable<T, D, %>

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

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

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

for (auto&& type : structs)
Expand All @@ -2921,14 +2968,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