launchdarkly / c-client-sdk

LaunchDarkly Client-side SDK for C/C++
Other
7 stars 15 forks source link

`kIOMasterPortDefault` is deprecated on macOS 12 #69

Closed scowalt closed 2 years ago

scowalt commented 2 years ago

Library version: 2.4.0

When compiling on macOS Monterey (Version 12.1), I get the following error:

/Users/scowalt/Code/c-client-sdk/src/ldutil.c:199:37: error: 'kIOMasterPortDefault' is deprecated: first deprecated in macOS 12.0 [-Werror,-Wdeprecated-declarations]
    entry = IORegistryEntryFromPath(kIOMasterPortDefault, "IOService:/");
                                    ^~~~~~~~~~~~~~~~~~~~
                                    kIOMainPortDefault
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/IOKit.framework/Headers/IOKitLib.h:123:19: note: 'kIOMasterPortDefault' has been explicitly marked deprecated here
const mach_port_t kIOMasterPortDefault
                  ^
1 error generated.
cwaldren-ld commented 2 years ago

Hi @scowalt, thanks for the report. I can reproduce. We'll take a look at this.

Filed internally as 139348.

scowalt commented 2 years ago

Sweet thanks!

For anyone else hit by this, I was able to work around the issue by turning off warnings for deprecation with -DCMAKE_C_FLAGS=-Wno-deprecated

cwaldren-ld commented 2 years ago

Hi @scowalt, this has been resolved in 2.4.1, and thanks again for reporting the issue.

When you get a chance, please confirm that the new release works for you.

scowalt commented 2 years ago

Weirdly, this introduced a new error for me:

/var/folders/l7/4zs8693n1fq5f517cmv4kv9m0000gn/T/tmp.ufGuF0kf/c-client-sdk/src/ldutil.c:205:37: error: 'kIOMainPortDefault' is only available on macOS 12.0 or newer [-Werror,-Wunguarded-availability-new]
    entry = IORegistryEntryFromPath(kIOMainPortDefault, "IOService:/");
                                    ^~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.1.sdk/System/Library/Frameworks/IOKit.framework/Headers/IOKitLib.h:102:19: note: 'kIOMainPortDefault' has been marked as being introduced in macOS 12.0 here, but the deployment target is macOS 11.0.0
const mach_port_t kIOMainPortDefault
                  ^
/var/folders/l7/4zs8693n1fq5f517cmv4kv9m0000gn/T/tmp.ufGuF0kf/c-client-sdk/src/ldutil.c:205:37: note: enclose 'kIOMainPortDefault' in a __builtin_available check to silence this warning
    entry = IORegistryEntryFromPath(kIOMainPortDefault, "IOService:/");
                                    ^~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/ldclientapi.dir/src/ldutil.c.o] Error 1
make[1]: *** [CMakeFiles/ldclientapi.dir/all] Error 2

I think it's because, even though my macOS version is 12, I'm specifying macOS version 11 as my build target. (This is something new that I wasn't doing when I originally filed this issue)

I'm specifying my build target with: set(CMAKE_OSX_DEPLOYMENT_TARGET "11" CACHE STRING "Minimum OS X deployment version" FORCE)

cwaldren-ld commented 2 years ago

@scowalt can you try find-and-replacing (here) MAC_OS_X_VERSION_MAX_ALLOWED with MAC_OS_X_VERSION_MIN_REQUIRED and let me know if that solves:

  1. The original use-case
  2. Your updated-use-case

Thanks.

scowalt commented 2 years ago

That fix appears to have works for both my original use case and the updated use case!

cwaldren-ld commented 2 years ago

Resolved by 2.4.2.