]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
getaddrinfo: Fix a compilation error in C++ mode (regression yesterday).
authorBruno Haible <bruno@clisp.org>
Thu, 13 Feb 2025 11:02:16 +0000 (12:02 +0100)
committerBruno Haible <bruno@clisp.org>
Thu, 13 Feb 2025 11:02:49 +0000 (12:02 +0100)
Reported by KO Myung-Hun <komh78@gmail.com>.

* m4/getaddrinfo.m4 (gl_GETADDRINFO): Don't set REPLACE_GETADDRINFO to 1
if getaddrinfo does not exist.

ChangeLog
m4/getaddrinfo.m4

index 8f5b7302b0379fb48b4aaef6777d4de6ab496512..51a17c3354fd08880a965d3492071fb1849f612c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2025-02-13  Bruno Haible  <bruno@clisp.org>
+
+       getaddrinfo: Fix a compilation error in C++ mode (regression yesterday).
+       Reported by KO Myung-Hun <komh78@gmail.com>.
+       * m4/getaddrinfo.m4 (gl_GETADDRINFO): Don't set REPLACE_GETADDRINFO to 1
+       if getaddrinfo does not exist.
+
 2025-02-12  Bruno Haible  <bruno@clisp.org>
 
        setlocale: Update info about Galician and Tamil.
index 19ae42cc157db019fd71fb40dc082e75d10fbaee..5207f0565f793288323eecbb15815117a9feaa75 100644 (file)
@@ -1,5 +1,5 @@
 # getaddrinfo.m4
-# serial 36
+# serial 37
 dnl Copyright (C) 2004-2025 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -89,10 +89,11 @@ int getaddrinfo (const char *, const char *, const struct addrinfo *, struct add
       HAVE_GETADDRINFO=0
     fi
   fi
-  AC_CACHE_CHECK([whether getaddrinfo supports AI_NUMERICSERV],
-    [gl_cv_func_getaddrinfo_works],
-    [AC_RUN_IFELSE(
-       [AC_LANG_PROGRAM([[
+  if test $HAVE_GETADDRINFO != 0; then
+    AC_CACHE_CHECK([whether getaddrinfo supports AI_NUMERICSERV],
+      [gl_cv_func_getaddrinfo_works],
+      [AC_RUN_IFELSE(
+         [AC_LANG_PROGRAM([[
 #include <sys/types.h>
 #ifdef HAVE_SYS_SOCKET_H
 #include <sys/socket.h>
@@ -105,28 +106,29 @@ int getaddrinfo (const char *, const char *, const struct addrinfo *, struct add
 #endif
 #include <stddef.h>
 #include <string.h>
-          ]], [[
-          struct addrinfo hints;
-          struct addrinfo ai;
-          memset (&hints, 0, sizeof (hints));
-          hints.ai_flags = AI_NUMERICSERV;
-          return getaddrinfo ("www.gnu.org", "http", &hints, &ai) != EAI_NONAME;
-          ]])
-       ],
-       [gl_cv_func_getaddrinfo_works=yes],
-       [gl_cv_func_getaddrinfo_works=no],
-       [case "$host_os" in
-                             # Guess no on native Windows.
-          mingw* | windows*) gl_cv_func_getaddrinfo_works="guessing no" ;;
-                             # Guess yes otherwise.
-          *)                 gl_cv_func_getaddrinfo_works="guessing yes" ;;
-        esac
-       ])
-    ])
-  case "$gl_cv_func_getaddrinfo_works" in
-    *yes) ;;
-    *) REPLACE_GETADDRINFO=1 ;;
-  esac
+            ]], [[
+              struct addrinfo hints;
+              struct addrinfo ai;
+              memset (&hints, 0, sizeof (hints));
+              hints.ai_flags = AI_NUMERICSERV;
+              return getaddrinfo ("www.gnu.org", "http", &hints, &ai) != EAI_NONAME;
+            ]])
+         ],
+         [gl_cv_func_getaddrinfo_works=yes],
+         [gl_cv_func_getaddrinfo_works=no],
+         [case "$host_os" in
+                               # Guess no on native Windows.
+            mingw* | windows*) gl_cv_func_getaddrinfo_works="guessing no" ;;
+                               # Guess yes otherwise.
+            *)                 gl_cv_func_getaddrinfo_works="guessing yes" ;;
+          esac
+         ])
+      ])
+    case "$gl_cv_func_getaddrinfo_works" in
+      *yes) ;;
+      *) REPLACE_GETADDRINFO=1 ;;
+    esac
+  fi
   AC_DEFINE_UNQUOTED([HAVE_GETADDRINFO], [$HAVE_GETADDRINFO],
     [Define to 1 if getaddrinfo exists, or to 0 otherwise.])