]> Savannah Git Hosting - gnulib.git/commitdiff
string: Avoid syntax error on glibc systems with GCC 11.
authorBruno Haible <bruno@clisp.org>
Sat, 30 Apr 2022 12:09:00 +0000 (14:09 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 31 Aug 2022 23:01:49 +0000 (01:01 +0200)
Reported by Tom Tromey <tromey@adacore.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2022-04/msg00075.html>
and by Satadru Pramanik <satadru@umich.edu> in
<https://lists.gnu.org/archive/html/bug-gnulib/2022-04/msg00076.html>.

* lib/string.in.h (strndup): Don't rededeclare strndup if it is defined
as a macro.

ChangeLog
lib/string.in.h

index 8fa5335e88e4bca275acdf446f960b74143f4283..6ce809d9b50c85aa00f0735e65debbdb5ebde686 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2022-04-30  Bruno Haible  <bruno@clisp.org>
+
+       string: Avoid syntax error on glibc systems with GCC 11.
+       Reported by Tom Tromey <tromey@adacore.com> in
+       <https://lists.gnu.org/archive/html/bug-gnulib/2022-04/msg00075.html>
+       and by Satadru Pramanik <satadru@umich.edu> in
+       <https://lists.gnu.org/archive/html/bug-gnulib/2022-04/msg00076.html>.
+       * lib/string.in.h (strndup): Don't rededeclare strndup if it is defined
+       as a macro.
+
 2022-04-28  Simon Marchi  <simon.marchi@efficios.com>  (tiny change)
 
        stdlib: Fix error in C++ mode on glibc systems (regr. 2022-04-13).
index b6840fa9121a7c93110039e7f912cd681c953778..33160b25254ac8ef752167332fa5901eb0748aff 100644 (file)
@@ -583,7 +583,7 @@ _GL_FUNCDECL_RPL (strndup, char *,
                   _GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE);
 _GL_CXXALIAS_RPL (strndup, char *, (char const *__s, size_t __n));
 # else
-#  if !@HAVE_DECL_STRNDUP@ || __GNUC__ >= 11
+#  if !@HAVE_DECL_STRNDUP@ || (__GNUC__ >= 11 && !defined strndup)
 _GL_FUNCDECL_SYS (strndup, char *,
                   (char const *__s, size_t __n)
                   _GL_ARG_NONNULL ((1))
@@ -593,7 +593,7 @@ _GL_CXXALIAS_SYS (strndup, char *, (char const *__s, size_t __n));
 # endif
 _GL_CXXALIASWARN (strndup);
 #else
-# if __GNUC__ >= 11
+# if __GNUC__ >= 11 && !defined strndup
 /* For -Wmismatched-dealloc: Associate strndup with free or rpl_free.  */
 _GL_FUNCDECL_SYS (strndup, char *,
                   (char const *__s, size_t __n)