130-fix-build-error-with-Xcode-16.3.patch 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. From 0a084bb6c04e453183530c3e20727be1cc55ff9a Mon Sep 17 00:00:00 2001
  2. From: Georgi Valkov <[email protected]>
  3. Date: Mon, 14 Apr 2025 15:18:00 +0300
  4. Subject: [PATCH] zlib: fix build error with Xcode 16.3
  5. Xcode 16.3 defines TARGET_OS_MAC, it was not defined in prior versions.
  6. zutil.h conditionally defines fdopen as NULL when this macro is defined,
  7. resulting in the following build error:
  8. /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/_stdio.h:318:7: error: expected identifier or '('
  9. 318 | FILE *fdopen(int, const char *) __DARWIN_ALIAS_STARTING(__MAC_10_6, __IPHONE_2_0, __DARWIN_ALIAS(fdopen));
  10. | ^
  11. ./zutil.h:147:33: note: expanded from macro 'fdopen'
  12. 147 | # define fdopen(fd,mode) NULL /* No fdopen() */
  13. In Xcode 16.2 and earlier, TARGET_OS_MAC was not defined so this entire
  14. block was ignored, gcc and gdb used to compile and work fine.
  15. This may have been used for compatibility with older versions of macOS,
  16. but is no longer needed. By pure luck, the build worked fine for a long
  17. time, because it did not properly detect macOS.
  18. Fixed by removing the check for TARGET_OS_MAC.
  19. Note that since Xcode 16.3, an entire set of TARGET_OS macros
  20. are now defined, most of which are set to 0:
  21. TARGET_OS_LINUX 0
  22. TARGET_OS_MAC 1
  23. TARGET_OS_OSX 1
  24. [1] https://github.com/openwrt/openwrt/pull/18467
  25. Signed-off-by: Georgi Valkov <[email protected]>
  26. ---
  27. zlib/zutil.h | 2 +-
  28. 1 file changed, 1 insertion(+), 1 deletion(-)
  29. --- a/zlib/zutil.h
  30. +++ b/zlib/zutil.h
  31. @@ -137,7 +137,7 @@ extern z_const char * const z_errmsg[10]
  32. # endif
  33. #endif
  34. -#if defined(MACOS) || defined(TARGET_OS_MAC)
  35. +#if defined(MACOS)
  36. # define OS_CODE 7
  37. # ifndef Z_SOLO
  38. # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os