Skip to content

Commit 5b9c5dc

Browse files
committed
cocoa_common: gate VoiceOver @available on 10.13 SDK
GCC 4.0 (Xcode 3.1, PowerPC) reports: cocoa_common.m:77: error: stray '@' in program @available(...) is a clang-only Obj-C extension (Xcode 7+, 2015). GCC 4.0 sees the '@' followed by a non-keyword identifier and bails. Same class of issue as the platform_darwin.m fixes in 2b51544, 6c80736, 27a843f, 2df15df. RAIsVoiceOverRunning() is called from configuration.c and needs to exist on every Cocoa build. NSWorkspace's isVoiceOverEnabled property is 10.13+; on older SDKs it doesn't exist anyway, so the only sensible behavior there is to return false. Wrap the @available block in #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101300. On 10.5-10.12 SDKs the block is preprocessed out entirely and the function falls through to the existing 'return false'. On 10.13+ SDKs (modern clang), behavior is unchanged. The other 10 @available sites in this file are already preprocessed out on macOS — they sit inside TARGET_OS_IOS, TARGET_OS_TV, HAVE_COCOATOUCH, or SDK-version gates that only trigger on newer build configurations.
1 parent 2020a2e commit 5b9c5dc

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

ui/drivers/cocoa/cocoa_common.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,14 @@ extern bool RAIsVoiceOverRunning(void)
7474
#import <AppKit/AppKit.h>
7575
extern bool RAIsVoiceOverRunning(void)
7676
{
77+
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101300
78+
/* @available is clang-only (Xcode 7+). GCC 4.0 rejects the
79+
* '@' as a stray token. isVoiceOverEnabled on NSWorkspace is
80+
* 10.13+ anyway, so on older SDKs we skip this block entirely
81+
* and fall through to the return below. */
7782
if (@available(macOS 10.13, *))
7883
return [[NSWorkspace sharedWorkspace] isVoiceOverEnabled];
84+
#endif
7985
return false;
8086
}
8187
#endif

0 commit comments

Comments
 (0)