From 8a31910e060d84ef1ba87fdf1e4dd6e449acb276 Mon Sep 17 00:00:00 2001 From: Pasukhin Dmitry Date: Wed, 28 Jan 2026 10:20:44 +0000 Subject: [PATCH] Coding - Fix compilation warnings (#1034) - Added version guard for Clang compiler to conditionally apply `-Wcast-function-type-mismatch` pragma - Wrapped deprecated `Standard_HMutex` typedef with deprecation warning suppression macros --- src/FoundationClasses/TKernel/Standard/Standard_Mutex.hxx | 6 ++++++ .../Standard/Standard_WarningDisableFunctionCast.hxx | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/FoundationClasses/TKernel/Standard/Standard_Mutex.hxx b/src/FoundationClasses/TKernel/Standard/Standard_Mutex.hxx index d2931c9d48..4a546e2732 100644 --- a/src/FoundationClasses/TKernel/Standard/Standard_Mutex.hxx +++ b/src/FoundationClasses/TKernel/Standard/Standard_Mutex.hxx @@ -173,8 +173,14 @@ private: }; //! @deprecated Use std::shared_ptr instead. Will be removed in OCCT 8.0.0. +Standard_DISABLE_DEPRECATION_WARNINGS; + +Standard_DEPRECATED("Standard_HMutex is deprecated; use std::shared_ptr instead. " + "Will be removed in OCCT 8.0.0") typedef NCollection_Shared Standard_HMutex; +Standard_ENABLE_DEPRECATION_WARNINGS; + // Implementation of the method Unlock is inline, since it is // just a shortcut to system function inline void Standard_Mutex::Unlock() diff --git a/src/FoundationClasses/TKernel/Standard/Standard_WarningDisableFunctionCast.hxx b/src/FoundationClasses/TKernel/Standard/Standard_WarningDisableFunctionCast.hxx index 9e9cbce603..798632a5c6 100644 --- a/src/FoundationClasses/TKernel/Standard/Standard_WarningDisableFunctionCast.hxx +++ b/src/FoundationClasses/TKernel/Standard/Standard_WarningDisableFunctionCast.hxx @@ -25,7 +25,9 @@ //! 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__) - #pragma clang diagnostic ignored "-Wcast-function-type-mismatch" + #if __clang_major__ >= 16 + #pragma clang diagnostic ignored "-Wcast-function-type-mismatch" + #endif #elif defined(__GNUC__) && !defined(__INTEL_COMPILER) #if (__GNUC__ > 8) || ((__GNUC__ == 8) && (__GNUC_MINOR__ >= 1)) #pragma GCC diagnostic ignored "-Wcast-function-type"