From e5d3de187f96a3d00c85ea8c91b4cbdcaee05371 Mon Sep 17 00:00:00 2001 From: Ryan Shepherd Date: Tue, 4 Feb 2025 16:15:34 -0800 Subject: [PATCH 1/5] Enable CFG on prebuild project --- prebuild/prebuild.vcxproj | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/prebuild/prebuild.vcxproj b/prebuild/prebuild.vcxproj index e5fa52565..26477b942 100644 --- a/prebuild/prebuild.vcxproj +++ b/prebuild/prebuild.vcxproj @@ -88,6 +88,7 @@ Disabled ..\cppwinrt MultiThreadedDebug + Guard Console @@ -98,6 +99,7 @@ Disabled ..\cppwinrt MultiThreadedDebug + Guard Console @@ -108,6 +110,7 @@ Disabled ..\cppwinrt MultiThreadedDebug + Guard Console @@ -120,6 +123,7 @@ true ..\cppwinrt MultiThreaded + Guard Console @@ -134,6 +138,7 @@ true ..\cppwinrt MultiThreaded + Guard Console @@ -148,6 +153,7 @@ true ..\cppwinrt MultiThreaded + Guard Console From 5078fb4f920b3127730939f4bd534a3d143642d4 Mon Sep 17 00:00:00 2001 From: Ryan Shepherd Date: Wed, 5 Feb 2025 11:22:11 -0800 Subject: [PATCH 2/5] Fix some more build warnings --- strings/base_composable.h | 7 +++++++ strings/base_implements.h | 7 +++++++ test/old_tests/Component/Component.idl | 4 ++++ test/test/fast_iterator.cpp | 2 +- test/test_component/OverloadClass.cpp | 6 +++--- 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/strings/base_composable.h b/strings/base_composable.h index 7f675c970..fe8538528 100644 --- a/strings/base_composable.h +++ b/strings/base_composable.h @@ -4,6 +4,10 @@ namespace winrt::impl template struct composable_factory { +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4702) +#endif template static I CreateInstance(const Windows::Foundation::IInspectable& outer, Windows::Foundation::IInspectable& inner, Args&&... args) { @@ -11,6 +15,9 @@ namespace winrt::impl inner = CreateInstanceImpl(outer, std::forward(args)...); return inner.as(); } +#ifdef _MSC_VER +#pragma warning(pop) +#endif private: template diff --git a/strings/base_implements.h b/strings/base_implements.h index 89b6c5790..8e413c83c 100644 --- a/strings/base_implements.h +++ b/strings/base_implements.h @@ -1390,6 +1390,10 @@ namespace winrt::impl WINRT_EXPORT namespace winrt { +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable: 4702) +#endif template auto make(Args&&... args) { @@ -1443,6 +1447,9 @@ WINRT_EXPORT namespace winrt return { impl::create_and_initialize(std::forward(args)...), take_ownership_from_abi }; } } +#ifdef _MSC_VER +#pragma warning(pop) +#endif template inline void clear_factory_static_lifetime() diff --git a/test/old_tests/Component/Component.idl b/test/old_tests/Component/Component.idl index 3c306ad69..c57901adf 100644 --- a/test/old_tests/Component/Component.idl +++ b/test/old_tests/Component/Component.idl @@ -243,6 +243,8 @@ namespace Component HRESULT Create([in] Windows.Foundation.Collections.IVectorView* _in, [out, retval] FastInputVector** _out); }; + midl_pragma warning(disable: 4066) + [version(1.0), activatable(IFastInputVectorFactory, 1.0)] runtimeclass FastInputVector { @@ -271,6 +273,8 @@ namespace Component interface Windows.Foundation.Collections.IMapView; }; + midl_pragma warning(default: 4066) + // // Boxing support for enums and their underlying types. // diff --git a/test/test/fast_iterator.cpp b/test/test/fast_iterator.cpp index 71ed6a918..f9e02dcec 100644 --- a/test/test/fast_iterator.cpp +++ b/test/test/fast_iterator.cpp @@ -48,7 +48,7 @@ TEST_CASE("fast_iterator") REQUIRE(2 - (vbegin + 4) > vbegin); REQUIRE(vbegin < vbegin + 2); REQUIRE(vbegin + 2 - 2 == vbegin); - REQUIRE(end(v) - begin(v) == v.Size()); + REQUIRE(static_cast(end(v) - begin(v)) == v.Size()); REQUIRE((begin(v) + 3)[-1] == 4); } { diff --git a/test/test_component/OverloadClass.cpp b/test/test_component/OverloadClass.cpp index d89f19ea5..0f78c5a1c 100644 --- a/test/test_component/OverloadClass.cpp +++ b/test/test_component/OverloadClass.cpp @@ -8,15 +8,15 @@ namespace winrt::test_component::implementation { throw hresult_not_implemented(); } - void OverloadClass::Overload(int a) + void OverloadClass::Overload(int /*a*/) { throw hresult_not_implemented(); } - void OverloadClass::Overload(int a, int b) + void OverloadClass::Overload(int /*a*/, int /*b*/) { throw hresult_not_implemented(); } - void OverloadClass::Overload(int a, int b, int c) + void OverloadClass::Overload(int /*a*/, int /*b*/, int /*c*/) { throw hresult_not_implemented(); } From df1b3b2d0b554d3577d05fa1c066437c7c6399ec Mon Sep 17 00:00:00 2001 From: Ryan Shepherd Date: Wed, 5 Feb 2025 12:06:05 -0800 Subject: [PATCH 3/5] A few more warnings. --- cppwinrt/component_writers.h | 3 +++ strings/base_composable.h | 2 +- strings/base_implements.h | 2 +- test/old_tests/Component/Component.idl | 2 +- test/test_component_base/HierarchyB.cpp | 2 ++ 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/cppwinrt/component_writers.h b/cppwinrt/component_writers.h index 4a2cce556..140d388b3 100644 --- a/cppwinrt/component_writers.h +++ b/cppwinrt/component_writers.h @@ -175,6 +175,9 @@ void* __stdcall %_get_activation_factory([[maybe_unused]] std::wstring_view cons int32_t __stdcall WINRT_CanUnloadNow() noexcept { #ifdef _WRL_MODULE_H_ +#ifdef _MSC_VER +#pragma warning(disable: 4324) // structure was padded due to alignment specifier +#endif if (!::Microsoft::WRL::Module<::Microsoft::WRL::InProc>::GetModule().Terminate()) { return 1; diff --git a/strings/base_composable.h b/strings/base_composable.h index fe8538528..e606d1292 100644 --- a/strings/base_composable.h +++ b/strings/base_composable.h @@ -6,7 +6,7 @@ namespace winrt::impl { #ifdef _MSC_VER #pragma warning(push) -#pragma warning(disable: 4702) +#pragma warning(disable: 4702) // Compiler bug causing spurious "unreachable code" warnings #endif template static I CreateInstance(const Windows::Foundation::IInspectable& outer, Windows::Foundation::IInspectable& inner, Args&&... args) diff --git a/strings/base_implements.h b/strings/base_implements.h index 8e413c83c..b943c1d96 100644 --- a/strings/base_implements.h +++ b/strings/base_implements.h @@ -1392,7 +1392,7 @@ WINRT_EXPORT namespace winrt { #ifdef _MSC_VER #pragma warning(push) -#pragma warning(disable: 4702) +#pragma warning(disable: 4702) // Compiler bug causing spurious "unreachable code" warnings #endif template auto make(Args&&... args) diff --git a/test/old_tests/Component/Component.idl b/test/old_tests/Component/Component.idl index c57901adf..ad51b5303 100644 --- a/test/old_tests/Component/Component.idl +++ b/test/old_tests/Component/Component.idl @@ -243,7 +243,7 @@ namespace Component HRESULT Create([in] Windows.Foundation.Collections.IVectorView* _in, [out, retval] FastInputVector** _out); }; - midl_pragma warning(disable: 4066) + midl_pragma warning(disable: 4066) // A member name has been qualified with an interface name because name collisions occurred across interface members on a runtime class. [version(1.0), activatable(IFastInputVectorFactory, 1.0)] runtimeclass FastInputVector diff --git a/test/test_component_base/HierarchyB.cpp b/test/test_component_base/HierarchyB.cpp index 34c73104f..30b9f09ff 100644 --- a/test/test_component_base/HierarchyB.cpp +++ b/test/test_component_base/HierarchyB.cpp @@ -1,6 +1,8 @@ #include "pch.h" #include "HierarchyB.h" +#pragma warning(disable: 4702) + namespace winrt::test_component_base::implementation { HierarchyB::HierarchyB(hstring const& name) From 4f847eebf73478f820a16cd0e1caec58d9009e32 Mon Sep 17 00:00:00 2001 From: Ryan Shepherd Date: Wed, 5 Feb 2025 16:41:13 -0800 Subject: [PATCH 4/5] Don't enable CFG on Debug builds --- prebuild/prebuild.vcxproj | 3 --- 1 file changed, 3 deletions(-) diff --git a/prebuild/prebuild.vcxproj b/prebuild/prebuild.vcxproj index 26477b942..6e0bc4b71 100644 --- a/prebuild/prebuild.vcxproj +++ b/prebuild/prebuild.vcxproj @@ -88,7 +88,6 @@ Disabled ..\cppwinrt MultiThreadedDebug - Guard Console @@ -99,7 +98,6 @@ Disabled ..\cppwinrt MultiThreadedDebug - Guard Console @@ -110,7 +108,6 @@ Disabled ..\cppwinrt MultiThreadedDebug - Guard Console From 557aa65c81e33076a7eecc78ae9f975d02157b04 Mon Sep 17 00:00:00 2001 From: Ryan Shepherd Date: Wed, 5 Feb 2025 16:43:29 -0800 Subject: [PATCH 5/5] Accidentally had a warning disable where I wanted suppress --- cppwinrt/component_writers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cppwinrt/component_writers.h b/cppwinrt/component_writers.h index 140d388b3..c52f49a13 100644 --- a/cppwinrt/component_writers.h +++ b/cppwinrt/component_writers.h @@ -176,7 +176,7 @@ int32_t __stdcall WINRT_CanUnloadNow() noexcept { #ifdef _WRL_MODULE_H_ #ifdef _MSC_VER -#pragma warning(disable: 4324) // structure was padded due to alignment specifier +#pragma warning(suppress: 4324) // structure was padded due to alignment specifier #endif if (!::Microsoft::WRL::Module<::Microsoft::WRL::InProc>::GetModule().Terminate()) {