pirate/mac-keyboard-brightness

OSX 10.9 CGDisplayIOServicePort is deprecated

yuzisee opened this issue · 3 comments

I found that the answer posted here works well https://stackoverflow.com/a/39589275

(Happy to submit a pull request if you like)

As is, you get something like:

$ gcc -std=c99 -o dbrightness display-brightness.c -framework IOKit -framework ApplicationServices
display-brightness.c:21:13: warning: 'CGDisplayIOServicePort' is deprecated:
      first deprecated in macOS 10.9 [-Wdeprecated-declarations]
  service = CGDisplayIOServicePort(targetDisplay);
            ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGDisplayConfiguration.h:372:24: note: 
      'CGDisplayIOServicePort' has been explicitly marked deprecated here
CG_EXTERN io_service_t CGDisplayIOServicePort(CGDirectDisplayID display)
                       ^
display-brightness.c:35:13: warning: 'CGDisplayIOServicePort' is deprecated:
      first deprecated in macOS 10.9 [-Wdeprecated-declarations]
  service = CGDisplayIOServicePort(targetDisplay);
            ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/System/Library/Frameworks/CoreGraphics.framework/Headers/CGDisplayConfiguration.h:372:24: note: 
      'CGDisplayIOServicePort' has been explicitly marked deprecated here
CG_EXTERN io_service_t CGDisplayIOServicePort(CGDirectDisplayID display)
                       ^
2 warnings generated.

After the fix, the resulting binary works fine for me and the warnings are gone.

In case it helps: #3

Awesome thanks!