macOS: kIOMasterPortDefault is deprecated #377

Closed
opened 2022-02-07 16:35:15 -06:00 by szechyjs · 4 comments
szechyjs commented 2022-02-07 16:35:15 -06:00 (Migrated from github.com)
hidapi/mac/hid.c:795:39: warning: 'kIOMasterPortDefault' is deprecated: first deprecated in macOS 12.0 [-Wdeprecated-declarations]
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/IOKit.framework/Headers/IOKitLib.h:123:19: note: 'kIOMasterPortDefault' has been explicitly marked deprecated here
In file included from ../go/pkg/mod/github.com/bearsh/hid@v1.4.0/hid_enabled.go:46:
hidapi/mac/hid.c:800:34: warning: 'kIOMasterPortDefault' is deprecated: first deprecated in macOS 12.0 [-Wdeprecated-declarations]
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/IOKit.framework/Headers/IOKitLib.h:123:19: note: 'kIOMasterPortDefault' has been explicitly marked deprecated here
``` hidapi/mac/hid.c:795:39: warning: 'kIOMasterPortDefault' is deprecated: first deprecated in macOS 12.0 [-Wdeprecated-declarations] /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/IOKit.framework/Headers/IOKitLib.h:123:19: note: 'kIOMasterPortDefault' has been explicitly marked deprecated here In file included from ../go/pkg/mod/github.com/bearsh/hid@v1.4.0/hid_enabled.go:46: hidapi/mac/hid.c:800:34: warning: 'kIOMasterPortDefault' is deprecated: first deprecated in macOS 12.0 [-Wdeprecated-declarations] /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/IOKit.framework/Headers/IOKitLib.h:123:19: note: 'kIOMasterPortDefault' has been explicitly marked deprecated here ```
Youw commented 2022-02-07 17:56:46 -06:00 (Migrated from github.com)

Has Apple provided an alternative?

Has Apple provided an alternative?
szechyjs commented 2022-02-07 19:21:32 -06:00 (Migrated from github.com)

Has Apple provided an alternative?

It looks like its kIOMainPortDefault

perhaps something like...

#if (MAC_OS_X_VERSION_MAX_ALLOWED < 120000) // Before macOS 12 Monterey
  #define kIOMainPortDefault kIOMasterPortDefault
#endif
> Has Apple provided an alternative? It looks like its `kIOMainPortDefault` perhaps something like... ```c #if (MAC_OS_X_VERSION_MAX_ALLOWED < 120000) // Before macOS 12 Monterey #define kIOMainPortDefault kIOMasterPortDefault #endif ```
mcuee commented 2022-02-08 21:01:25 -06:00 (Migrated from github.com)

Interestingly libusb uses a simple way to do this. I am not saying it is a better way though.
https://github.com/libusb/libusb/blob/master/libusb/os/darwin_usb.c#L57

/* Both kIOMasterPortDefault or kIOMainPortDefault are synonyms for 0. */
static const mach_port_t darwin_default_master_port = 0;

Ref:
https://developer.apple.com/documentation/iokit/kiomasterportdefault
https://developer.apple.com/documentation/iokit/kiomainportdefault
This is a synonym for NULL, if you'd rather use a named constant.

Interestingly libusb uses a simple way to do this. I am not saying it is a better way though. https://github.com/libusb/libusb/blob/master/libusb/os/darwin_usb.c#L57 ``` /* Both kIOMasterPortDefault or kIOMainPortDefault are synonyms for 0. */ static const mach_port_t darwin_default_master_port = 0; ``` Ref: https://developer.apple.com/documentation/iokit/kiomasterportdefault https://developer.apple.com/documentation/iokit/kiomainportdefault This is a synonym for NULL, if you'd rather use a named constant.
Youw commented 2022-02-09 06:20:34 -06:00 (Migrated from github.com)

Thanks for the alternative

Thanks for the alternative
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-libusb/hidapi#377
No description provided.