On 08/11/2023 03:54, Paul Eggert wrote:
OK, how about if we do something like this instead? I hope the "101300" is the right version, and the business with __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ is taken from unistd.in.h.

On the system you have macOS 12.5 running, if you check
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/AvailabilityMacros.h you should be able to get the accurate value for macOS 13 (if the system is up to date, you'll have the definition for the subsequent release usually). My guess is 130000, since the value for macOS 11 is 110000. After macOS 10.15, they moved to macOS 11, 12, 13, 14.

__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ is defined in cpp(1).
I can't confirm on newer macOS versions but it would be safe to assume AvailabilityMacros.h is available if (defined __APPLE__ && defined __MACH__) since the header covers mobile & desktop.

Untested:

--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -38,8 +38,11 @@

 /* Suppress macOS deprecation warnings for sprintf and vsprintf.  */
 #if (defined __APPLE__ && defined __MACH__) && !defined _POSIX_C_SOURCE
+# include <AvailabilityMacros.h>
+# if defined(MAC_OS_X_VERSION_MIN_REQUIRED) && MAC_OS_X_VERSION_MIN_REQUIRED >= 130000
 # define _POSIX_C_SOURCE 200809L
 # define _GL_DEFINED__POSIX_C_SOURCE
+# endif
 #endif

 #define _GL_ALREADY_INCLUDING_STDIO_H
--


Sevan

Reply via email to