changeset 15438:591ddd1ddd1a

Declare system functions in a way that works with C++. * m4/fdopendir.m4 (gl_FUNC_FDOPENDIR) [C++]: In the test program, declare fdopendir as extern "C". * m4/frexpl.m4 (gl_FUNC_FREXPL_WORKS) [C++]: In the test program, declare frexpl as extern "C". * m4/getaddrinfo.m4 (gl_GETADDRINFO) [C++]: In the test program, declare gai_strerror as extern "C". * m4/getdomainname.m4 (gl_FUNC_GETDOMAINNAME) [C++]: In the test programs, declare gai_strerror as extern "C". * m4/getlogin_r.m4 (gl_FUNC_GETLOGIN_R) [C++]: In the test program, declare getlogin_r as extern "C". * m4/ioctl.m4 (gl_FUNC_IOCTL) [C++]: In the test program, declare ioctl as extern "C". * m4/ldexpl.m4 (gl_FUNC_LDEXPL_WORKS) [C++]: In the test program, declare ldexpl as extern "C". * m4/logb.m4 (gl_FUNC_LOGB) [C++]: In the test programs, declare logb as extern "C". * m4/ls-mntd-fs.m4 (gl_LIST_MOUNTED_FILE_SYSTEMS) [C++]: In the test program, declare getmntinfo as extern "C". * m4/stpncpy.m4 (gl_FUNC_STPNCPY) [C++]: In the test program, declare stpncpy as extern "C". * m4/strerror_r.m4 (gl_FUNC_STRERROR_R_WORKS) [C++]: In the test program, declare __xpg_strerror_r as extern "C". * m4/strndup.m4 (gl_FUNC_STRNDUP) [C++]: In the test program, declare strndup as extern "C". * m4/sys_select_h.m4 (gl_HEADER_SYS_SELECT) [C++]: In the test program, declare memset and bzero as extern "C". Reported by Sam Steingold <sds@gnu.org>.
author Bruno Haible <bruno@clisp.org>
date Fri, 22 Jul 2011 00:16:46 +0200
parents 055938f44a46
children 12875e5545b9
files ChangeLog m4/fdopendir.m4 m4/frexpl.m4 m4/getaddrinfo.m4 m4/getdomainname.m4 m4/getlogin_r.m4 m4/ioctl.m4 m4/ldexpl.m4 m4/logb.m4 m4/ls-mntd-fs.m4 m4/stpncpy.m4 m4/strerror_r.m4 m4/strndup.m4 m4/sys_select_h.m4
diffstat 14 files changed, 126 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,34 @@
+2011-07-21  Bruno Haible  <bruno@clisp.org>
+
+	Declare system functions in a way that works with C++.
+	* m4/fdopendir.m4 (gl_FUNC_FDOPENDIR) [C++]: In the test program,
+	declare fdopendir as extern "C".
+	* m4/frexpl.m4 (gl_FUNC_FREXPL_WORKS) [C++]: In the test program,
+	declare frexpl as extern "C".
+	* m4/getaddrinfo.m4 (gl_GETADDRINFO) [C++]: In the test program,
+	declare gai_strerror as extern "C".
+	* m4/getdomainname.m4 (gl_FUNC_GETDOMAINNAME) [C++]: In the test
+	programs, declare gai_strerror as extern "C".
+	* m4/getlogin_r.m4 (gl_FUNC_GETLOGIN_R) [C++]: In the test program,
+	declare getlogin_r as extern "C".
+	* m4/ioctl.m4 (gl_FUNC_IOCTL) [C++]: In the test program, declare ioctl
+	as extern "C".
+	* m4/ldexpl.m4 (gl_FUNC_LDEXPL_WORKS) [C++]: In the test program,
+	declare ldexpl as extern "C".
+	* m4/logb.m4 (gl_FUNC_LOGB) [C++]: In the test programs, declare logb
+	as extern "C".
+	* m4/ls-mntd-fs.m4 (gl_LIST_MOUNTED_FILE_SYSTEMS) [C++]: In the test
+	program, declare getmntinfo as extern "C".
+	* m4/stpncpy.m4 (gl_FUNC_STPNCPY) [C++]: In the test program, declare
+	stpncpy as extern "C".
+	* m4/strerror_r.m4 (gl_FUNC_STRERROR_R_WORKS) [C++]: In the test
+	program, declare __xpg_strerror_r as extern "C".
+	* m4/strndup.m4 (gl_FUNC_STRNDUP) [C++]: In the test program, declare
+	strndup as extern "C".
+	* m4/sys_select_h.m4 (gl_HEADER_SYS_SELECT) [C++]: In the test program,
+	declare memset and bzero as extern "C".
+	Reported by Sam Steingold <sds@gnu.org>.
+
 2011-07-12  Jim Meyering  <meyering@redhat.com>
 
 	maint.mk: prohibit inclusion of "verify.h" without use
--- a/m4/fdopendir.m4
+++ b/m4/fdopendir.m4
@@ -1,4 +1,4 @@
-# serial 7
+# serial 8
 # See if we need to provide fdopendir.
 
 dnl Copyright (C) 2009-2011 Free Software Foundation, Inc.
@@ -26,7 +26,11 @@
 #include <fcntl.h>
 #include <unistd.h>
 #if !HAVE_DECL_FDOPENDIR
-extern DIR *fdopendir (int);
+extern
+# ifdef __cplusplus
+"C"
+# endif
+DIR *fdopendir (int);
 #endif
 ]], [int result = 0;
      int fd = open ("conftest.c", O_RDONLY);
--- a/m4/frexpl.m4
+++ b/m4/frexpl.m4
@@ -1,4 +1,4 @@
-# frexpl.m4 serial 14
+# frexpl.m4 serial 15
 dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -115,7 +115,11 @@
 # undef LDBL_MIN_EXP
 # define LDBL_MIN_EXP    (-16381)
 #endif
-extern long double frexpl (long double, int *);
+extern
+#ifdef __cplusplus
+"C"
+#endif
+long double frexpl (long double, int *);
 int main()
 {
   int result = 0;
--- a/m4/getaddrinfo.m4
+++ b/m4/getaddrinfo.m4
@@ -1,4 +1,4 @@
-# getaddrinfo.m4 serial 26
+# getaddrinfo.m4 serial 27
 dnl Copyright (C) 2004-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -92,7 +92,11 @@
 #include <ws2tcpip.h>
 #endif
 #include <stddef.h>
-extern const char *gai_strerror(int);]])],
+extern
+#ifdef __cplusplus
+"C"
+#endif
+const char *gai_strerror(int);]])],
         [gl_cv_func_gai_strerror_posix_signature=yes],
         [gl_cv_func_gai_strerror_posix_signature=no])])
     if test $gl_cv_func_gai_strerror_posix_signature = no; then
--- a/m4/getdomainname.m4
+++ b/m4/getdomainname.m4
@@ -1,4 +1,4 @@
-# getdomainname.m4 serial 7
+# getdomainname.m4 serial 8
 dnl Copyright (C) 2002-2003, 2008-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -28,7 +28,11 @@
        AC_LINK_IFELSE(
          [AC_LANG_PROGRAM(
             [[#include <stddef.h>
-              extern int getdomainname (char *, size_t);
+              extern
+              #ifdef __cplusplus
+              "C"
+              #endif
+              int getdomainname (char *, size_t);
             ]],
             [[getdomainname(NULL, 0);]])],
          [gl_cv_func_getdomainname_in_libnsl=yes])
@@ -63,7 +67,12 @@
               #include <netdb.h>
               #endif
               #include <unistd.h>
-              extern int getdomainname (char *, int);]],
+              extern
+              #ifdef __cplusplus
+              "C"
+              #endif
+              int getdomainname (char *, int);
+            ]],
             [[]])],
          [gl_cv_decl_getdomainname_argtype2='int'],
          [gl_cv_decl_getdomainname_argtype2='size_t'])
--- a/m4/getlogin_r.m4
+++ b/m4/getlogin_r.m4
@@ -1,4 +1,4 @@
-#serial 10
+#serial 11
 
 # Copyright (C) 2005-2007, 2009-2011 Free Software Foundation, Inc.
 #
@@ -50,7 +50,11 @@
 #include <stddef.h>
 #include <unistd.h>
 #if !HAVE_DECL_GETLOGIN_R
-extern int getlogin_r (char *, size_t);
+extern
+# ifdef __cplusplus
+"C"
+# endif
+int getlogin_r (char *, size_t);
 #endif
 int
 main (void)
--- a/m4/ioctl.m4
+++ b/m4/ioctl.m4
@@ -1,4 +1,4 @@
-# ioctl.m4 serial 3
+# ioctl.m4 serial 4
 dnl Copyright (C) 2008-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -24,7 +24,12 @@
       [AC_COMPILE_IFELSE(
          [AC_LANG_PROGRAM(
             [[#include <sys/ioctl.h>]],
-            [[extern int ioctl (int, int, ...);]])
+            [[extern
+              #ifdef __cplusplus
+              "C"
+              #endif
+              int ioctl (int, int, ...);
+            ]])
          ],
          [gl_cv_func_ioctl_posix_signature=yes],
          [gl_cv_func_ioctl_posix_signature=no])
--- a/m4/ldexpl.m4
+++ b/m4/ldexpl.m4
@@ -1,4 +1,4 @@
-# ldexpl.m4 serial 11
+# ldexpl.m4 serial 12
 dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -86,7 +86,11 @@
       AC_RUN_IFELSE(
         [AC_LANG_SOURCE([[
 #include <math.h>
-extern long double ldexpl (long double, int);
+extern
+#ifdef __cplusplus
+"C"
+#endif
+long double ldexpl (long double, int);
 int main()
 {
   int result = 0;
--- a/m4/logb.m4
+++ b/m4/logb.m4
@@ -1,4 +1,4 @@
-# logb.m4 serial 2
+# logb.m4 serial 3
 dnl Copyright (C) 2010-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -20,7 +20,11 @@
          # define __NO_MATH_INLINES 1 /* for glibc */
          #endif
          #include <math.h>
-         extern double logb (double x);
+         extern
+         #ifdef __cplusplus
+         "C"
+         #endif
+         double logb (double x);
          double x;]],
        [[x = logb(x);]])],
     [LOGB_LIBM=])
@@ -33,7 +37,11 @@
            # define __NO_MATH_INLINES 1 /* for glibc */
            #endif
            #include <math.h>
-           extern double logb (double x);
+           extern
+           #ifdef __cplusplus
+           "C"
+           #endif
+           double logb (double x);
            double x;]],
          [[x = logb(x);]])],
       [LOGB_LIBM="-lm"])
--- a/m4/ls-mntd-fs.m4
+++ b/m4/ls-mntd-fs.m4
@@ -1,4 +1,4 @@
-# serial 28
+# serial 29
 # How to list mounted file systems.
 
 # Copyright (C) 1998-2004, 2006, 2009-2011 Free Software Foundation, Inc.
@@ -247,7 +247,11 @@
 #if HAVE_SYS_STATVFS_H
 # include <sys/statvfs.h>
 #endif
-extern int getmntinfo (struct statfs **, int);
+extern
+#ifdef __cplusplus
+"C"
+#endif
+int getmntinfo (struct statfs **, int);
             ]], [])],
           [fu_cv_sys_mounted_getmntinfo2=no],
           [fu_cv_sys_mounted_getmntinfo2=yes])
--- a/m4/stpncpy.m4
+++ b/m4/stpncpy.m4
@@ -1,4 +1,4 @@
-# stpncpy.m4 serial 14
+# stpncpy.m4 serial 15
 dnl Copyright (C) 2002-2003, 2005-2007, 2009-2011 Free Software Foundation,
 dnl Inc.
 dnl This file is free software; the Free Software Foundation
@@ -35,7 +35,11 @@
 #include <string.h> /* for strcpy */
 /* The stpncpy prototype is missing in <string.h> on AIX 4.  */
 #if !HAVE_DECL_STPNCPY
-extern char *stpncpy (char *dest, const char *src, size_t n);
+extern
+# ifdef __cplusplus
+"C"
+# endif
+char *stpncpy (char *dest, const char *src, size_t n);
 #endif
 int main ()
 {
--- a/m4/strerror_r.m4
+++ b/m4/strerror_r.m4
@@ -1,4 +1,4 @@
-# strerror_r.m4 serial 12
+# strerror_r.m4 serial 13
 dnl Copyright (C) 2002, 2007-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -138,7 +138,11 @@
                [AC_LANG_PROGRAM(
                   [[#include <errno.h>
                     #include <string.h>
-                    extern int __xpg_strerror_r(int, char *, size_t);
+                    extern
+                    #ifdef __cplusplus
+                    "C"
+                    #endif
+                    int __xpg_strerror_r(int, char *, size_t);
                   ]],
                   [[int result = 0;
                     char buf[256] = "^";
--- a/m4/strndup.m4
+++ b/m4/strndup.m4
@@ -1,4 +1,4 @@
-# strndup.m4 serial 19
+# strndup.m4 serial 20
 dnl Copyright (C) 2002-2003, 2005-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -25,7 +25,11 @@
          AC_LANG_PROGRAM([[#include <string.h>
                            #include <stdlib.h>]], [[
 #ifndef HAVE_DECL_STRNDUP
-  extern char *strndup (const char *, size_t);
+  extern
+  #ifdef __cplusplus
+  "C"
+  #endif
+  char *strndup (const char *, size_t);
 #endif
   char *s;
   s = strndup ("some longer string", 15);
--- a/m4/sys_select_h.m4
+++ b/m4/sys_select_h.m4
@@ -1,4 +1,4 @@
-# sys_select_h.m4 serial 19
+# sys_select_h.m4 serial 20
 dnl Copyright (C) 2006-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -32,10 +32,18 @@
              [AC_LANG_PROGRAM([[#include <sys/select.h>]], [[
                   #undef memset
                   #define memset nonexistent_memset
-                  extern void *memset (void *, int, unsigned long);
+                  extern
+                  #ifdef __cplusplus
+                  "C"
+                  #endif
+                  void *memset (void *, int, unsigned long);
                   #undef bzero
                   #define bzero nonexistent_bzero
-                  extern void bzero (void *, unsigned long);
+                  extern
+                  #ifdef __cplusplus
+                  "C"
+                  #endif
+                  void bzero (void *, unsigned long);
                   fd_set fds;
                   FD_ZERO (&fds);
                 ]])