Bug in the recent macOS 12.0 build fix
This commit:
https://github.com/karalabe/usb/commit/c7c6bc0112904e38bff30fb4ed81ecefc0db8fca#diff-030195b530be26a69d54ce9487a942a3b24568c08397d003492f4507e1217f16R33
uses MAC_OS_X_VERSION_MAX_ALLOWED to determine whether to use the old or new name. This definition can be 120000 even if compiling on macOS 11, resulting in compiler warnings and a broken build.
It looks like MAC_OS_X_VERSION_MIN_REQUIRED should be used instead?
Like in this patch:
https://bug-224632-attachments.webkit.org/attachment.cgi?id=426166 (from https://bugs.webkit.org/show_bug.cgi?id=224632).
For reference, here is the error I ran when compiling on macOS 11:
n file included from vendor/github.com/karalabe/usb/libs.go:50:
vendor/github.com/karalabe/usb/libusb/libusb/os/darwin_usb.c:253:39: warning: 'kIOMainPortDefault' is only available on macOS 12.0 or newer [-Wunguarded-availability-new]
When I print the MAC_OS_X_VERSION_MAX_ALLOWED var during compilation, it was shown to be 120000.
Running into this again. @karalabe is this package still maintained?
The above fix was suboptimal also in that it uses the definition made in libusb inside of hidapi, even though these are separate libraries. The two libraries have in the meantime fixed it upstream by simply using 0 instead of kIOMainPortDefault. It would be good to pull the latest upstream changes instead of doing local patches.