Pierre Ossman reported in <https://savannah.gnu.org/bugs/?67300>:
> Trying to build the latest release of gettext using GCC 15 and macOS > as the target results in: > > > ... > In file included from > /usr/x86_64-apple-darwin10/sys-root/usr/include/secure/_string.h:32, > from > /usr/x86_64-apple-darwin10/sys-root/usr/include/string.h:148, > from ./string.h:41, > from getcwd-lgpl.c:24: > ./string.h:754:20: error: expected declaration specifiers or '...' before > numeric constant > 754 | _GL_EXTERN_C void *memcpy (void *__dest, const void *__src, > size_t __n) > | ^~~~~~ > ./string.h:754:20: error: expected ')' before '!=' token > 754 | _GL_EXTERN_C void *memcpy (void *__dest, const void *__src, > size_t __n) > | ^~~~~~ > ./string.h:754:20: error: expected ')' before '?' token > 754 | _GL_EXTERN_C void *memcpy (void *__dest, const void *__src, > size_t __n) > | ^~~~~~ > ... > > > The issue seems to be that macOS uses defines to redirect these functions to > _chk versions. When that define gets expanded in these new gnulib lines, > everything breaks. Thanks for the report. This patch should fix it. 2025-07-10 Bruno Haible <br...@clisp.org> string-h: Fix compilation error on macOS with fortify. Reported by Pierre Ossman <oss...@cendio.se> at <https://savannah.gnu.org/bugs/?67300>. * lib/string.in.h (memcpy etc.): Don't redeclare functions that are declared as macros. diff --git a/lib/string.in.h b/lib/string.in.h index e3d94b76c1..9a039c7ba0 100644 --- a/lib/string.in.h +++ b/lib/string.in.h @@ -214,65 +214,85 @@ _GL_EXTERN_C void free (void *); /* Declarations for ISO C N3322. */ #if defined __GNUC__ && __GNUC__ >= 15 && !defined __clang__ +# ifndef memcpy _GL_EXTERN_C void *memcpy (void *__dest, const void *__src, size_t __n) -# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 +# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_ATTRIBUTE_NOTHROW -# endif +# endif _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3) _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3); +# endif +# ifndef memccpy _GL_EXTERN_C void *memccpy (void *__dest, const void *__src, int __c, size_t __n) -# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 +# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_ATTRIBUTE_NOTHROW -# endif +# endif _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 4) _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 4); +# endif +# ifndef memmove _GL_EXTERN_C void *memmove (void *__dest, const void *__src, size_t __n) -# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 +# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_ATTRIBUTE_NOTHROW -# endif +# endif _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3) _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3); +# endif +# ifndef strncpy _GL_EXTERN_C char *strncpy (char *__dest, const char *__src, size_t __n) -# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 +# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_ATTRIBUTE_NOTHROW -# endif +# endif _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3) _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3); +# endif +# ifndef strndup _GL_EXTERN_C char *strndup (const char *__s, size_t __n) -# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 +# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_ATTRIBUTE_NOTHROW -# endif +# endif _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2); +# endif +# ifndef strncat _GL_EXTERN_C char *strncat (char *__dest, const char *__src, size_t __n) -# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 +# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_ATTRIBUTE_NOTHROW -# endif +# endif _GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3); +# endif +# ifndef memcmp _GL_EXTERN_C int memcmp (const void *__s1, const void *__s2, size_t __n) -# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 +# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_ATTRIBUTE_NOTHROW -# endif +# endif _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3) _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3); +# endif +# ifndef strncmp _GL_EXTERN_C int strncmp (const char *__s1, const char *__s2, size_t __n) -# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 +# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_ATTRIBUTE_NOTHROW -# endif +# endif _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3) _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3); -# ifndef __cplusplus +# endif +# if !defined memchr && !defined __cplusplus _GL_EXTERN_C void *memchr (const void *__s, int __c, size_t __n) _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3); _GL_EXTERN_C void *memrchr (const void *__s, int __c, size_t __n) _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3); # endif +# ifndef memset _GL_EXTERN_C void *memset (void *__s, int __c, size_t __n) -# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 +# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2 _GL_ATTRIBUTE_NOTHROW -# endif +# endif _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3); +# endif +# ifndef memset_explicit _GL_EXTERN_C void *memset_explicit (void *__s, int __c, size_t __n) _GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3); +# endif #endif