From 381568a11a484f1d91f1f4cd50c7db4db563102c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 16 Oct 2025 21:22:17 +0200 Subject: [PATCH] Platform: more -Wcast-function-type suppressions for Clang 13+. Followup to 235db64cf6a5b4eef89d847914980a20c2df8081, as now I have clang-cl 19.1 on the AppVeyor CI MSVC 2022 image and can see the warnings now. --- .../Platform/Implementation/DpiScaling.cpp | 3 ++- .../Platform/WindowlessWglApplication.cpp | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/Magnum/Platform/Implementation/DpiScaling.cpp b/src/Magnum/Platform/Implementation/DpiScaling.cpp index 26ca65048..c9878a4c5 100644 --- a/src/Magnum/Platform/Implementation/DpiScaling.cpp +++ b/src/Magnum/Platform/Implementation/DpiScaling.cpp @@ -171,7 +171,8 @@ bool isWindowsAppDpiAware() { /* 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. Clang implements it since version 13, - and it's a part of -Wextra since 19.1: + and it's a part of -Wextra since 19.1, thus warning when clang-cl + 19.1+ is used: https://github.com/llvm/llvm-project/commit/217f0f735afec57a51fa6f9ab863d4713a2f85e2 https://github.com/llvm/llvm-project/commit/1de7e6c8cba27296f3fc16d107822ea0ee856759 diff --git a/src/Magnum/Platform/WindowlessWglApplication.cpp b/src/Magnum/Platform/WindowlessWglApplication.cpp index 3cdcda054..648f49ffe 100644 --- a/src/Magnum/Platform/WindowlessWglApplication.cpp +++ b/src/Magnum/Platform/WindowlessWglApplication.cpp @@ -121,10 +121,31 @@ WindowlessWglContext::WindowlessWglContext(const Configuration& configuration, G /* Get pointer to proper context creation function */ typedef HGLRC(WINAPI*PFNWGLCREATECONTEXTATTRIBSARBPROC)(HDC, HGLRC, const int*); + + /* 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. Clang implements it since version 13, and it's a part + of -Wextra since 19.1, thus warning when clang-cl 19.1+ is used: + https://github.com/llvm/llvm-project/commit/217f0f735afec57a51fa6f9ab863d4713a2f85e2 + https://github.com/llvm/llvm-project/commit/1de7e6c8cba27296f3fc16d107822ea0ee856759 + OTOH, without the __extension__ it causes a -Wpedantic warning on GCC + 4.8 (and perhaps newer), so we need both. + + 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 #ifdef CORRADE_TARGET_GCC __extension__ /* https://web.archive.org/web/20160826013457/http://www.mr-edd.co.uk/blog/supressing_gcc_warnings */ #endif const PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = reinterpret_cast( wglGetProcAddress(reinterpret_cast("wglCreateContextAttribsARB"))); + #if (defined(CORRADE_TARGET_GCC) && !defined(CORRADE_TARGET_CLANG) && __GNUC__ >= 8) || (defined(CORRADE_TARGET_CLANG) && __clang_major__ >= 13) + #pragma GCC diagnostic pop + #endif /* Request debug context if GpuValidation is enabled either via the configuration or via command-line */