Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warning: 'kIOMasterPortDefault' is deprecated: first deprecated in macOS 12.0 #8

Open
n8felton opened this issue Jul 31, 2023 · 2 comments

Comments

@n8felton
Copy link

% sw_vers
ProductName:		macOS
ProductVersion:		13.5
BuildVersion:		22G74

% xcodebuild -version

Xcode 14.3
Build version 14E222b

image

main.cpp:102:56: warning: 'kIOMasterPortDefault' is deprecated: first deprecated in macOS 12.0 [-Wdeprecated-declarations]
    io_service_t service = IOServiceGetMatchingService(kIOMasterPortDefault, matching);
                                                       ^~~~~~~~~~~~~~~~~~~~
                                                       kIOMainPortDefault
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/IOKit.framework/Headers/IOKitLib.h:133:19: note: 'kIOMasterPortDefault' has been explicitly marked deprecated here
const mach_port_t kIOMasterPortDefault
                  ^
main.cpp:130:38: warning: 'kIOMasterPortDefault' is deprecated: first deprecated in macOS 12.0 [-Wdeprecated-declarations]
    if (IOServiceGetMatchingServices(kIOMasterPortDefault, matching, &iter) != kIOReturnSuccess)
                                     ^~~~~~~~~~~~~~~~~~~~
                                     kIOMainPortDefault
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/IOKit.framework/Headers/IOKitLib.h:133:19: note: 'kIOMasterPortDefault' has been explicitly marked deprecated here
const mach_port_t kIOMasterPortDefault
                  ^

Changing kIOMainPortDefault to just 0 should work. Hoping to test and submit PR, but documenting it for now.

@n8felton
Copy link
Author

Of course after hitting submit I realize that all they're really doing is renaming kIOMasterPortDefault to kIOMainPortDefault. (Master to Main)

@n8felton
Copy link
Author

Option 1

Switch kIOMasterPortDefault to kIOMainPortDefault but kIOMainPortDefault will only work with macOS 12+ unless we do something like libusb/hidapi#377 (comment)

#if (MAC_OS_X_VERSION_MAX_ALLOWED < 120000) // Before macOS 12 Monterey
  #define kIOMainPortDefault kIOMasterPortDefault
#endif

Option 2

When specifying a primary port to IOKit functions, the NULL argument indicates "use the default". This is a synonym for NULL, if you'd rather use a named constant.

kIOMasterPortDefault and kIOMainPortDefault are just synonyms for NULL, which is just 0 in C++. So, change kIOMasterPortDefault to 0 and not care about which version of macOS/Xcode we're compiling for/on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant