]> Savannah Git Hosting - gnulib.git/commitdiff
strerror_r-posix: Fix override of AC_FUNC_STRERROR_R
authorEric Blake <eblake@redhat.com>
Fri, 4 Nov 2016 19:06:39 +0000 (14:06 -0500)
committerEric Blake <eblake@redhat.com>
Sat, 12 Nov 2016 20:50:11 +0000 (14:50 -0600)
Requiring autoconf's AC_FUNC_STRERROR_R and then calling AC_DEFINE
ourselves leads to two insertions of #define STRERROR_R_CHAR_P
in confdefs.h, but with different values (at least on glibc).  This
in turn sparks a gcc warning about redeclaring the macro, and kills
any subsequent tests that use -Werror (which now error because of
the conflicting define, whether or not the test used to error).

A better approach is to replace the autoconf macro with a version
of our own that doesn't probe anything, so that the AC_DEFINE is
reached exactly once.

* m4/strerror_r.m4 (AC_FUNC_STRERROR_R): New override.
(gl_FUNC_STRERROR_R): Don't reuse AC_DEFINE() with a potentially
different value.

Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
m4/strerror_r.m4

index 8233beab74f164bc333547dace11c0585b558adb..dec04d9a33429e5913202e924ade7281cd35a89c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2016-11-12  Eric Blake  <eblake@redhat.com>
+
+       strerror_r-posix: Fix override of AC_FUNC_STRERROR_R
+       * m4/strerror_r.m4 (AC_FUNC_STRERROR_R): New override.
+       (gl_FUNC_STRERROR_R): Don't reuse AC_DEFINE() with a potentially
+       different value.
+
 2016-11-09  Frediano Ziglio  <fziglio@redhat.com>
 
        manywarnings: fix -Wno-missing-field-initializers detection
index 06c51e156fdeb0cc4d8df80d2aef31629fd4e967..7fd08a867bf3a2863782b3b96eb05000cebbdb31 100644 (file)
@@ -1,4 +1,4 @@
-# strerror_r.m4 serial 16
+# strerror_r.m4 serial 17
 dnl Copyright (C) 2002, 2007-2016 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -41,8 +41,17 @@ AC_DEFUN([gl_FUNC_STRERROR_R],
 
   # Overwrite the findings of AC_FUNC_STRERROR_R (for code that uses that).
   AC_REQUIRE([AC_FUNC_STRERROR_R])
-  AC_DEFINE([HAVE_DECL_STRERROR_R], [1])
-  AC_DEFINE([STRERROR_R_CHAR_P], [0])
+])
+
+# If this module is in use, we unconditionally want POSIX semantics; so
+# replace autoconf's macro with a version that does not probe
+AC_DEFUN([AC_FUNC_STRERROR_R], [
+  AC_DEFINE([HAVE_DECL_STRERROR_R], [1],
+    [Define to 1, since you should have the declaration of strerror_r.])
+  AC_DEFINE([HAVE_STRERROR_R], [1],
+    [Define to 1, since you should have the function strerror_r.])
+  AC_DEFINE([STRERROR_R_CHAR_P], [0],
+    [Define to 0, since strerror_r should not return char *.])
 ])
 
 # Prerequisites of lib/strerror_r.c.