瀏覽代碼

Merge pull request #2316 from endrift/macos-gcc

Common: Fix gcc build on macOS
bunnei 9 年之前
父節點
當前提交
a89471621b
共有 1 個文件被更改,包括 11 次插入0 次删除
  1. 11 0
      src/common/file_util.cpp

+ 11 - 0
src/common/file_util.cpp

@@ -40,9 +40,20 @@
 #endif
 #endif
 
 
 #if defined(__APPLE__)
 #if defined(__APPLE__)
+// CFURL contains __attribute__ directives that gcc does not know how to parse, so we need to just
+// ignore them if we're not using clang. The macro is only used to prevent linking against
+// functions that don't exist on older versions of macOS, and the worst case scenario is a linker
+// error, so this is perfectly safe, just inconvenient.
+#ifndef __clang__
+#define availability(...)
+#endif
 #include <CoreFoundation/CFBundle.h>
 #include <CoreFoundation/CFBundle.h>
 #include <CoreFoundation/CFString.h>
 #include <CoreFoundation/CFString.h>
 #include <CoreFoundation/CFURL.h>
 #include <CoreFoundation/CFURL.h>
+#ifdef availability
+#undef availability
+#endif
+
 #endif
 #endif
 
 
 #include <algorithm>
 #include <algorithm>