From 235db64cf6a5b4eef89d847914980a20c2df8081 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 4 Sep 2025 15:58:35 +0200 Subject: [PATCH] Platform: expand -Wcast-function-type warning suppression to Clang 13+. --- .../Platform/Implementation/DpiScaling.cpp | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/Magnum/Platform/Implementation/DpiScaling.cpp b/src/Magnum/Platform/Implementation/DpiScaling.cpp index a6e885972..fb3c507ed 100644 --- a/src/Magnum/Platform/Implementation/DpiScaling.cpp +++ b/src/Magnum/Platform/Implementation/DpiScaling.cpp @@ -170,17 +170,21 @@ bool isWindowsAppDpiAware() { 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. - - Also explicitly check we're not on Clang because certain Clang-based - IDEs inherit __GNUC__ if GCC is used instead of leaving it at 4 like - Clang itself does. */ - #if defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ >= 8 + we're doing, so suppress that. Clang implements it since version 13, + and it's a part of -Wextra since 19.1: + https://github.com/llvm/llvm-project/commit/217f0f735afec57a51fa6f9ab863d4713a2f85e2 + https://github.com/llvm/llvm-project/commit/1de7e6c8cba27296f3fc16d107822ea0ee856759 + + For GCC explicitly check we're not on Clang because certain + Clang-based IDEs inherit __GNUC__ if GCC is used instead of leaving + it at 4 like Clang itself does, which could lead to the pragma + being used on Clang 12 and older, causing unknown pragma warning. */ + #if (defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ >= 8) || (defined(CORRADE_TARGET_CLANG) && __clang_major__ >= 13) #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) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ >= 8 + #if (defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ >= 8) || (defined(CORRADE_TARGET_CLANG) && __clang_major__ >= 13) #pragma GCC diagnostic pop #endif PROCESS_DPI_AWARENESS result{}; @@ -193,19 +197,13 @@ 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. - - Also explicitly check we're not on Clang because certain Clang-based - IDEs inherit __GNUC__ if GCC is used instead of leaving it at 4 like - Clang itself does. */ - #if defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ >= 8 + /* Same as above */ + #if (defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ >= 8) || (defined(CORRADE_TARGET_CLANG) && __clang_major__ >= 13) #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) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ >= 8 + #if (defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ >= 8) || (defined(CORRADE_TARGET_CLANG) && __clang_major__ >= 13) #pragma GCC diagnostic pop #endif CORRADE_INTERNAL_ASSERT(isProcessDPIAware);