From aa64d4482fa720184000544ea575b8fa09c393c7 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Tue, 8 Apr 2025 02:03:14 +0800 Subject: [PATCH] macOS: Define _DARWIN_C_SOURCE in more sources Restore Darwin APIs removed by `_POSIX_C_SOURCE`. --- Source/cmLoadCommandCommand.cxx | 6 ++++++ Source/cmStandardLexer.h | 6 ++++++ Source/cmTimestamp.cxx | 7 +++++++ 3 files changed, 19 insertions(+) diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx index 81edea5b61..3e994514c5 100644 --- a/Source/cmLoadCommandCommand.cxx +++ b/Source/cmLoadCommandCommand.cxx @@ -11,6 +11,12 @@ // NOLINTNEXTLINE(bugprone-reserved-identifier) # define _XOPEN_SOURCE 700 #endif +#if defined(__APPLE__) +// Restore Darwin APIs removed by _POSIX_C_SOURCE: +// aligned_alloc +// NOLINTNEXTLINE(bugprone-reserved-identifier) +# define _DARWIN_C_SOURCE +#endif #include "cmLoadCommandCommand.h" diff --git a/Source/cmStandardLexer.h b/Source/cmStandardLexer.h index 27225280d6..e39deb0a90 100644 --- a/Source/cmStandardLexer.h +++ b/Source/cmStandardLexer.h @@ -23,6 +23,12 @@ // NOLINTNEXTLINE(bugprone-reserved-identifier) # define _XOPEN_SOURCE 700 #endif +#if defined(__APPLE__) +// Restore Darwin APIs removed by _POSIX_C_SOURCE: +// aligned_alloc +// NOLINTNEXTLINE(bugprone-reserved-identifier) +# define _DARWIN_C_SOURCE +#endif #include "cmsys/Configure.h" // IWYU pragma: keep diff --git a/Source/cmTimestamp.cxx b/Source/cmTimestamp.cxx index 4d8bc027d8..e3e3e25381 100644 --- a/Source/cmTimestamp.cxx +++ b/Source/cmTimestamp.cxx @@ -11,6 +11,13 @@ // NOLINTNEXTLINE(bugprone-reserved-identifier) # define _XOPEN_SOURCE 700 #endif +#if defined(__APPLE__) +// Restore Darwin APIs removed by _POSIX_C_SOURCE: +// aligned_alloc +// timespec_get +// NOLINTNEXTLINE(bugprone-reserved-identifier) +# define _DARWIN_C_SOURCE +#endif #include "cmTimestamp.h"