aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2019-07-26 21:56:55 +0200
committerTeddy Wing2019-07-26 22:02:54 +0200
commitdf494a923b6ecec23a2f0b03689826ee24e139af (patch)
treef64a36e17336729fd243fc2629ab7d286cad6b97
parentf2fa635d0474eae70a9d869b7d90423e85c5baef (diff)
downloadsystray-use-mac-os-version-value-instead-of-macro.tar.bz2
systray_darwin.m: Compare Mac OS min version with value instead of macrouse-mac-os-version-value-instead-of-macro
I was getting this error building on Mac OS X 10.12: $ pwd <$GOPATH>/src/github.com/getlantern/systray/example $ go run . # github.com/getlantern/systray systray_darwin.m:132:22: error: use of undeclared identifier 'NSControlStateValueOn' systray_darwin.m:134:22: error: use of undeclared identifier 'NSControlStateValueOff' The `NSControlStateValueOn` and `NSControlStateValueOff` were not defined because Mac OS versions prior to 10.14 don't define `__MAC_10_14`. From `/usr/include/Availability.h`: > It is also possible to use the *_VERSION_MIN_REQUIRED in source code to make one > source base that can be compiled to target a range of OS versions. It is best > to not use the _MAC_* and __IPHONE_* macros for comparisons, but rather their values. > That is because you might get compiled on an old OS that does not define a later > OS version macro, and in the C preprocessor undefined values evaluate to zero > in expresssions, which could cause the #if expression to evaluate in an unexpected > way. > > #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED > // code only compiled when targeting Mac OS X and not iPhone > // note use of 1050 instead of __MAC_10_5 > #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050 > // code in here might run on pre-Leopard OS > #else > // code here can assume Leopard or later > #endif > #endif See #75, #92.
-rw-r--r--systray_darwin.m2
1 files changed, 1 insertions, 1 deletions
diff --git a/systray_darwin.m b/systray_darwin.m
index ad8902b..b0f2172 100644
--- a/systray_darwin.m
+++ b/systray_darwin.m
@@ -1,7 +1,7 @@
#import <Cocoa/Cocoa.h>
#include "systray.h"
-#if __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_14
+#if __MAC_OS_X_VERSION_MIN_REQUIRED < 101400
#ifndef NSControlStateValueOff
#define NSControlStateValueOff NSOffState