From 6606f5163605247df4b97d21f75ca7d3d07323c2 Mon Sep 17 00:00:00 2001 From: Luflosi Date: Wed, 21 Apr 2021 16:23:42 +0200 Subject: [PATCH] Fix compilation on macOS 10.12 The constants `NSControlStateValueOn`, `NSControlStateValueOff` and `NSControlStateValueMixed` are only available for macOS 10.13 or above according to https://developer.apple.com/documentation/appkit/nscontrolstatevalueon?language=objc. Without this commit, compilation fails with this message: ``` glfw/cocoa_window.m:1537:28: error: use of undeclared identifier 'NSControlStateValueOn' item.state = NSControlStateValueOn; ^ glfw/cocoa_window.m:1539:28: error: use of undeclared identifier 'NSControlStateValueMixed' item.state = NSControlStateValueMixed; ^ glfw/cocoa_window.m:1542:47: error: use of undeclared identifier 'NSControlStateValueOn' item.state = controller.isDesired ? NSControlStateValueOn : NSControlStateValueOff; ^ glfw/cocoa_window.m:1542:71: error: use of undeclared identifier 'NSControlStateValueOff' item.state = controller.isDesired ? NSControlStateValueOn : NSControlStateValueOff; ^ ``` To fix this, simply redefine the constants to use the old and now deprecated constants on older macOS versions. The code that causes this was introduced in 98519bf326834a126e89489a6a221ff21fab100f. --- glfw/cocoa_window.m | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index 3217c9f0e..899f6b15d 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -32,6 +32,12 @@ #include #include +#if (MAC_OS_X_VERSION_MAX_ALLOWED < 101300) +#define NSControlStateValueOn NSOnState +#define NSControlStateValueOff NSOffState +#define NSControlStateValueMixed NSMixedState +#endif + static uint32_t vk_code_to_functional_key_code(uint8_t key_code) { // {{{