From 19d1693323f7b30a483600e1de8e7556d7fde955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 18 Oct 2020 17:11:47 +0200 Subject: [PATCH] Platform: suppress a warning specific to MinGW GCC 8+. --- .../Platform/Implementation/DpiScaling.cpp | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Magnum/Platform/Implementation/DpiScaling.cpp b/src/Magnum/Platform/Implementation/DpiScaling.cpp index 262e972f6..25feecc7b 100644 --- a/src/Magnum/Platform/Implementation/DpiScaling.cpp +++ b/src/Magnum/Platform/Implementation/DpiScaling.cpp @@ -155,7 +155,17 @@ bool isWindowsAppDpiAware() { need. */ HMODULE const shcore = GetModuleHandleA("Shcore.dll"); if(shcore) { + /* GCC 8 adds -Wcast-function-type, enabled by default with -Wextra, + which causes this line to emit a warning on MinGW. We know what + we're doing, so suppress that. */ + #if defined(CORRADE_TARGET_GCC) && __GNUC__ >= 8 + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wcast-function-type" + #endif auto* const getProcessDpiAwareness = reinterpret_cast(GetProcAddress(shcore, "GetProcessDpiAwareness")); + #if defined(CORRADE_TARGET_GCC) && __GNUC__ >= 8 + #pragma GCC diagnostic pop + #endif PROCESS_DPI_AWARENESS result{}; return getProcessDpiAwareness && getProcessDpiAwareness(nullptr, &result) == S_OK && result != PROCESS_DPI_UNAWARE; } @@ -166,7 +176,17 @@ bool isWindowsAppDpiAware() { correctly. */ HMODULE const user32 = GetModuleHandleA("User32.dll"); CORRADE_INTERNAL_ASSERT(user32); + /* GCC 8 adds -Wcast-function-type, enabled by default with -Wextra, which + causes this line to emit a warning on MinGW. We know what we're doing, + so suppress that. */ + #if defined(CORRADE_TARGET_GCC) && __GNUC__ >= 8 + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wcast-function-type" + #endif auto const isProcessDPIAware = reinterpret_cast(GetProcAddress(user32, "IsProcessDPIAware")); + #if defined(CORRADE_TARGET_GCC) && __GNUC__ >= 8 + #pragma GCC diagnostic pop + #endif CORRADE_INTERNAL_ASSERT(isProcessDPIAware); return isProcessDPIAware(); }