Coding - Suppress macOS system header warnings in multiple files (#997)

- Added clang diagnostic pragmas to suppress three specific warning types around macOS/iOS framework imports
- Added version-specific warning suppression for clang 20+ in the general warnings disable header
- Extended function cast warning suppression to cover clang's `-Wcast-function-type-mismatch`
This commit is contained in:
Pasukhin Dmitry
2026-01-14 21:22:11 +00:00
committed by GitHub
parent 0a1e8b7802
commit b5cd7a8410
8 changed files with 44 additions and 2 deletions

View File

@@ -13,7 +13,13 @@
#if defined(__APPLE__) && !defined(HAVE_XLIB)
// Suppress warnings from macOS system headers
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#pragma clang diagnostic ignored "-Wmissing-method-return-type"
#pragma clang diagnostic ignored "-Wavailability"
#import <Cocoa/Cocoa.h>
#pragma clang diagnostic pop
#include <Draw_Window.hxx>
#include <Cocoa_LocalPool.hxx>

View File

@@ -13,7 +13,13 @@
#if defined(__APPLE__) && !defined(HAVE_XLIB)
// Suppress warnings from macOS system headers
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#pragma clang diagnostic ignored "-Wmissing-method-return-type"
#pragma clang diagnostic ignored "-Wavailability"
#import <Cocoa/Cocoa.h>
#pragma clang diagnostic pop
#include <Cocoa_Window.hxx>
#include <ViewerTest.hxx>

View File

@@ -24,7 +24,9 @@
//! 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(__GNUC__) && !defined(__INTEL_COMPILER) && !defined(__clang__)
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wcast-function-type-mismatch"
#elif defined(__GNUC__) && !defined(__INTEL_COMPILER)
#if (__GNUC__ > 8) || ((__GNUC__ == 8) && (__GNUC_MINOR__ >= 1))
#pragma GCC diagnostic ignored "-Wcast-function-type"
#endif

View File

@@ -33,6 +33,9 @@
#pragma clang diagnostic ignored "-Wextra"
#pragma clang diagnostic ignored "-Wshorten-64-to-32"
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#if __clang_major__ >= 20
#pragma clang diagnostic ignored "-Wnontrivial-memcall"
#endif
#elif defined(_MSC_VER)
#pragma warning(push, 0)
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))

View File

@@ -24,11 +24,17 @@
#import <TargetConditionals.h>
// Suppress warnings from macOS system headers
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#pragma clang diagnostic ignored "-Wmissing-method-return-type"
#pragma clang diagnostic ignored "-Wavailability"
#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#else
#import <Cocoa/Cocoa.h>
#endif
#pragma clang diagnostic pop
#include <OpenGl_GlCore11.hxx>
#include <OpenGl_Context.hxx>

View File

@@ -24,17 +24,24 @@
#import <TargetConditionals.h>
// Suppress warnings from macOS system headers
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#pragma clang diagnostic ignored "-Wmissing-method-return-type"
#pragma clang diagnostic ignored "-Wavailability"
#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#else
#import <Cocoa/Cocoa.h>
#endif
#pragma clang diagnostic pop
#if !defined(TARGET_OS_IPHONE) || !TARGET_OS_IPHONE
#if !defined(MAC_OS_X_VERSION_10_7) || (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7)
@interface NSView (LionAPI)
- (NSSize )convertSizeToBacking: (NSSize )theSize;
@end
#endif
#endif
#include <OpenGl_Window.hxx>

View File

@@ -17,11 +17,17 @@
#import <TargetConditionals.h>
// Suppress warnings from macOS system headers
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#pragma clang diagnostic ignored "-Wmissing-method-return-type"
#pragma clang diagnostic ignored "-Wavailability"
#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#else
#import <Cocoa/Cocoa.h>
#endif
#pragma clang diagnostic pop
#ifndef HAVE_OBJC_ARC

View File

@@ -15,11 +15,17 @@
#import <TargetConditionals.h>
// Suppress warnings from macOS system headers
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
#pragma clang diagnostic ignored "-Wmissing-method-return-type"
#pragma clang diagnostic ignored "-Wavailability"
#if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
#import <UIKit/UIKit.h>
#else
#import <Cocoa/Cocoa.h>
#endif
#pragma clang diagnostic pop
#include <Cocoa_Window.hxx>