From 8949fd25f9f9ff0d276417a028d25ecfa6963398 Mon Sep 17 00:00:00 2001 From: Pasukhin Dmitry Date: Tue, 10 Feb 2026 18:13:04 +0000 Subject: [PATCH] Coding - Fix clang warning suppression for function pointer casts (#1059) - Switched from `__clang_major__ >= 16` gating to `__has_warning(...)` checks - Added fallback suppression for `-Wcast-function-type` when `-Wcast-function-type-mismatch` is unavailable --- .../Standard/Standard_WarningDisableFunctionCast.hxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/FoundationClasses/TKernel/Standard/Standard_WarningDisableFunctionCast.hxx b/src/FoundationClasses/TKernel/Standard/Standard_WarningDisableFunctionCast.hxx index 798632a5c6..29f6076984 100644 --- a/src/FoundationClasses/TKernel/Standard/Standard_WarningDisableFunctionCast.hxx +++ b/src/FoundationClasses/TKernel/Standard/Standard_WarningDisableFunctionCast.hxx @@ -24,9 +24,11 @@ //! There is no way to prevent this warning at OCCT level (until safer APIs is introduced), thus //! suppressing it is the only feasible way to avoid it. As this warning still can point out broken //! places, it should be suppressed only locally, where usage of function cast has been verified. -#if defined(__clang__) - #if __clang_major__ >= 16 +#if defined(__clang__) && defined(__has_warning) + #if __has_warning("-Wcast-function-type-mismatch") #pragma clang diagnostic ignored "-Wcast-function-type-mismatch" + #elif __has_warning("-Wcast-function-type") + #pragma clang diagnostic ignored "-Wcast-function-type" #endif #elif defined(__GNUC__) && !defined(__INTEL_COMPILER) #if (__GNUC__ > 8) || ((__GNUC__ == 8) && (__GNUC_MINOR__ >= 1))