From 60d5a30b3b8f4b100c1bd387c61f6fbf32690d32 Mon Sep 17 00:00:00 2001 From: Kazuki Sakamoto Date: Fri, 28 Oct 2016 22:46:20 -0700 Subject: [PATCH] Fix "Symbol not found: _os_log_type_enabled" on 10.11 or earlier --- src/MacVim/MacVim.h | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/MacVim/MacVim.h b/src/MacVim/MacVim.h index a820f73002..9f4aaf0f38 100644 --- a/src/MacVim/MacVim.h +++ b/src/MacVim/MacVim.h @@ -30,13 +30,15 @@ # define MAC_OS_X_VERSION_10_12 101200 #endif -// Needed for pre-10.11 SDK #ifndef NSAppKitVersionNumber10_10 # define NSAppKitVersionNumber10_10 1343 #endif #ifndef NSAppKitVersionNumber10_10_Max # define NSAppKitVersionNumber10_10_Max 1349 #endif +#ifndef NSAppKitVersionNumber10_12 +# define NSAppKitVersionNumber10_12 1504 +#endif #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12 // Deprecated constants in 10.12 SDK @@ -70,8 +72,8 @@ # define NSWindowStyleMaskUnifiedTitleAndToolbar NSUnifiedTitleAndToolbarWindowMask #endif +#import #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12 -# import # define MM_USE_ASL #else # import @@ -425,9 +427,26 @@ void ASLInit(); # define MM_ASL_LEVEL_DEFAULT OS_LOG_TYPE_DEFAULT # define ASLog(level, fmt, ...) \ if (level <= ASLogLevel) { \ - os_log_with_type(OS_LOG_DEFAULT, level, "%s@%d: %s", \ - __PRETTY_FUNCTION__, __LINE__, \ - [[NSString stringWithFormat:fmt, ##__VA_ARGS__] UTF8String]); \ + if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_12) { \ + os_log_with_type(OS_LOG_DEFAULT, level, "%s@%d: %s", \ + __PRETTY_FUNCTION__, __LINE__, \ + [[NSString stringWithFormat:fmt, ##__VA_ARGS__] UTF8String]); \ + } else { \ + int logLevel; \ + switch (level) { \ + case OS_LOG_TYPE_FAULT: logLevel = ASL_LEVEL_CRIT; break; \ + case OS_LOG_TYPE_ERROR: logLevel = ASL_LEVEL_ERR; break; \ + case OS_LOG_TYPE_INFO: logLevel = ASL_LEVEL_INFO; break; \ + case OS_LOG_TYPE_DEBUG: logLevel = ASL_LEVEL_DEBUG; break; \ + default: logLevel = ASL_LEVEL_NOTICE; break; \ + } \ + _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \ + asl_log(NULL, NULL, logLevel, "%s@%d: %s", \ + __PRETTY_FUNCTION__, __LINE__, \ + [[NSString stringWithFormat:fmt, ##__VA_ARGS__] UTF8String]); \ + _Pragma("clang diagnostic pop") \ + } \ } # define ASLogCrit(fmt, ...) ASLog(OS_LOG_TYPE_FAULT, fmt, ##__VA_ARGS__)