From c4157d4ac9c074a491f8ed0daec9cc4b7cf16f4b Mon Sep 17 00:00:00 2001 From: Raymond Chen Date: Thu, 9 Jul 2020 09:54:13 -0700 Subject: [PATCH] Disable warning 4458 in delegates Delegates derive from app-provided classes, which means that any function parameter in the delegate methods could potentially hide a member from the app-provided class. Delegates don't actually care because the only thing from the base class they use is the function call operator, which isn't a named member. Disable the warning to avoid triggering false alarms in projects that build with all warnings enabled. --- strings/base_delegate.h | 9 +++++++++ test/test/pch.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/strings/base_delegate.h b/strings/base_delegate.h index e3995dd11..fa1484dd2 100644 --- a/strings/base_delegate.h +++ b/strings/base_delegate.h @@ -1,6 +1,11 @@ namespace winrt::impl { +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4458) // declaration hides class member (okay because we do not use named members of base class) +#endif + template struct implements_delegate : abi_t, H, update_module_lock { @@ -187,6 +192,10 @@ namespace winrt::impl return { static_cast(new variadic_delegate(std::forward(handler))), take_ownership_from_abi }; } }; + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif } WINRT_EXPORT namespace winrt diff --git a/test/test/pch.h b/test/test/pch.h index f027fb732..ea74230cc 100644 --- a/test/test/pch.h +++ b/test/test/pch.h @@ -1,5 +1,7 @@ #pragma once +#pragma warning(4: 4458) // ensure we compile clean with this warning enabled + #define WINRT_LEAN_AND_MEAN #include #include "winrt/Windows.Foundation.Collections.h"