Archived issue #0031021

Coding Rules - Deprecation warnings on OSX within Draw_Window_1.mm

CommunityOCCT:Codingclosed7 public notes

Search issues

Description

[user path removed]/util/ESP/opencascade-7.4/trunk/src/Draw/Draw_Window_1.mm:564:60: warning: 'NSPNGFileType' is deprecated: first deprecated in macOS 10.14 [-Wdeprecated-declarations]
                                  [NSNumber numberWithInt: NSPNGFileType], @"png",
                                                           ^~~~~~~~~~~~~
                                                           NSBitmapImageFileTypePNG
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSBitmapImageRep.h:157:36: note: 'NSPNGFileType' has been explicitly marked
      deprecated here
static const NSBitmapImageFileType NSPNGFileType API_DEPRECATED_WITH_REPLACEMENT("NSBitmapImageFileTypePNG", macos(10.0,10.14)) = NSBitmapImageFileTypePNG;
                                   ^
[user path removed]/util/ESP/opencascade-7.4/trunk/src/Draw/Draw_Window_1.mm:565:60: warning: 'NSBMPFileType' is deprecated: first deprecated in macOS 10.14 [-Wdeprecated-declarations]
                                  [NSNumber numberWithInt: NSBMPFileType], @"bmp",
                                                           ^~~~~~~~~~~~~
                                                           NSBitmapImageFileTypeBMP
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSBitmapImageRep.h:154:36: note: 'NSBMPFileType' has been explicitly marked
      deprecated here
static const NSBitmapImageFileType NSBMPFileType API_DEPRECATED_WITH_REPLACEMENT("NSBitmapImageFileTypeBMP", macos(10.0,10.14)) = NSBitmapImageFileTypeBMP;
                                   ^
[user path removed]/util/ESP/opencascade-7.4/trunk/src/Draw/Draw_Window_1.mm:566:60: warning: 'NSJPEGFileType' is deprecated: first deprecated in macOS 10.14 [-Wdeprecated-declarations]
                                  [NSNumber numberWithInt: NSJPEGFileType], @"jpg",
                                                           ^~~~~~~~~~~~~~
                                                           NSBitmapImageFileTypeJPEG
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSBitmapImageRep.h:156:36: note: 'NSJPEGFileType' has been explicitly marked
      deprecated here
static const NSBitmapImageFileType NSJPEGFileType API_DEPRECATED_WITH_REPLACEMENT("NSBitmapImageFileTypeJPEG", macos(10.0,10.14)) = NSBitmapImageFileTypeJPEG;
                                   ^
[user path removed]/util/ESP/opencascade-7.4/trunk/src/Draw/Draw_Window_1.mm:567:60: warning: 'NSGIFFileType' is deprecated: first deprecated in macOS 10.14 [-Wdeprecated-declarations]
                                  [NSNumber numberWithInt: NSGIFFileType], @"gif",
                                                           ^~~~~~~~~~~~~
                                                           NSBitmapImageFileTypeGIF
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSBitmapImageRep.h:155:36: note: 'NSGIFFileType' has been explicitly marked
      deprecated here
static const NSBitmapImageFileType NSGIFFileType API_DEPRECATED_WITH_REPLACEMENT("NSBitmapImageFileTypeGIF", macos(10.0,10.14)) = NSBitmapImageFileTypeGIF;

[user path removed]/util/ESP/opencascade-7.4/trunk/src/OpenGl/OpenGl_Window_1.mm:213:17: warning: 'setView:' is deprecated: first deprecated in macOS 10.14 - Use NSOpenGLView to provide OpenGL content in a Cocoa app.
      [-Wdeprecated-declarations]
    [aGLContext setView: aView];
                ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSOpenGL.h:202:36: note: property 'view' is declared deprecated here
@property (nullable, weak) NSView *view API_DEPRECATED("", macos(10.0,10.14));
                                   ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSOpenGL.h:203:1: note: 'setView:' has been explicitly marked deprecated here
- (void)setView:(nullable NSView *)view API_DEPRECATED("Use NSOpenGLView to provide OpenGL content in a Cocoa app.", macos(10.0,10.14));
^
[user path removed]/util/ESP/opencascade-7.4/trunk/src/OpenGl/OpenGl_Window_1.mm:270:29: warning: 'view' is deprecated: first deprecated in macOS 10.14 [-Wdeprecated-declarations]
    NSView* aView = [aGLCtx view];
                            ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSOpenGL.h:202:36: note: property 'view' is declared deprecated here
@property (nullable, weak) NSView *view API_DEPRECATED("", macos(10.0,10.14));
                                   ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSOpenGL.h:202:36: note: 'view' has been explicitly marked deprecated here
[user path removed]/util/ESP/opencascade-7.4/trunk/src/OpenGl/OpenGl_Window_1.mm:350:38: warning: 'view' is deprecated: first deprecated in macOS 10.14 [-Wdeprecated-declarations]
  NSView* aView = [aGLCtx view];
                                     ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSOpenGL.h:202:36: note: property 'view' is declared deprecated here
@property (nullable, weak) NSView *view API_DEPRECATED("", macos(10.0,10.14));
                                   ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSOpenGL.h:202:36: note: 'view' has been explicitly marked deprecated here

[user path removed]/util/ESP/opencascade-7.4/trunk/src/Aspect/Aspect_RenderingContext.hxx:40:13: warning: 'NSOpenGLContext' is deprecated: first deprecated in macOS 10.14 - Please use Metal or MetalKit. [-Wdeprecated-declarations]
    typedef NSOpenGLContext* Aspect_RenderingContext;
            ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSOpenGL.h:193:12: note: 'NSOpenGLContext' has been explicitly marked deprecated
      here
@interface NSOpenGLContext : NSObject <NSLocking>
           ^

Steps to reproduce

Compile OCCT on OSX 10.14 or newer.

Public activity

7 archived notes

Participants are labeled by their role within this record.

01Commenter 3
There is nothing OCCT can do with these warnings (of course, apart from suppressing them intentionally).

After many years of silently abandoned state of OpenGL in macOS, Apple has confirmed the sad fact of ignorance of industrial cross-platform standards, and marked this framework as "deprecated", which means that they are not going to support it further and may remove it with some further release.

So yes, user building OCCT for macOS is expected to see this warning, because OCCT visualization functionality will be limited by obsolete state of OpenGL framework within official SDK, and is incomparable to OpenGL support on other platforms (Windows, Linux).

There is no yet alternative to switch onto.
One of possible directions is using Vulkan implementation over Metal (so far, Apple also ignores another new open standard - Vulkan graphics API):
https://github.com/KhronosGroup/MoltenVK

P.S.: a couple of warnings related to enumeration renames (NSBitmapImageFileTypePNG) can be fixed.

02Author
Yeah I thought that would be the case. Apple does not like to play with other peoples toys, or let others play with their toys.

It would be nice if the enumerations could get fixed.
03Commenter 3
> It would be nice if the enumerations could get fixed.
You can prepare a patch.
I think it should be similar to this one #0029156 also related to deprecated enums:
https://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff;h=[revision removed]
04Author
This patch suppresses the enumeration warnings. I tried it on OSX 10.15 and 10.12. I only compiled. I don't use OCC graphics and I would not know how to do a runtime test.

Index: Draw_Window_1.mm
===================================================================
--- Draw_Window_1.mm (revision 1)
+++ Draw_Window_1.mm (working copy)
@@ -37,6 +37,13 @@
   #define NSCompositingOperationSourceOver NSCompositeSourceOver
 #endif
 
+#if !defined(MAC_OS_X_VERSION_10_14) || (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_14)
+ #define NSBitmapImageFileTypePNG NSPNGFileType
+ #define NSBitmapImageFileTypeBMP NSBMPFileType
+ #define NSBitmapImageFileTypeJPEG NSJPEGFileType
+ #define NSBitmapImageFileTypeGIF NSGIFFileType
+#endif
+
 @interface Draw_CocoaView : NSView
 {
   NSImage* myImage;
@@ -561,10 +568,10 @@
   NSString* aFileExtension = [[aFileName pathExtension] lowercaseString];
 
   NSDictionary* aFileTypeDict = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSNumber numberWithInt: NSPNGFileType], @"png",
- [NSNumber numberWithInt: NSBMPFileType], @"bmp",
- [NSNumber numberWithInt: NSJPEGFileType], @"jpg",
- [NSNumber numberWithInt: NSGIFFileType], @"gif",
+ [NSNumber numberWithInt: NSBitmapImageFileTypePNG], @"png",
+ [NSNumber numberWithInt: NSBitmapImageFileTypeBMP], @"bmp",
+ [NSNumber numberWithInt: NSBitmapImageFileTypeJPEG], @"jpg",
+ [NSNumber numberWithInt: NSBitmapImageFileTypeGIF], @"gif",
                                   nil];
   if ([aFileTypeDict valueForKey: aFileExtension] == NULL)
   {
05Commenter 4
Branch [archived branch] has been created by Commenter 3.

[revision removed]


Detailed log of new commits:

Author: Commenter 3
Date: Tue Oct 15 20:46:57 2019 +0300

    0031021: Coding Rules - Deprecation warnings on OSX within Draw_Window_1.mm
    
    Use new renamed enumeration values instead of deprecated ones.
06Commenter 3
Please raise the patch.
07Commenter 4
Branch [archived branch] has been deleted by Commenter 3.

[revision removed]

Related records