Declare system functions in a way that works with C++.
authorBruno Haible <bruno@clisp.org>
Thu, 21 Jul 2011 22:16:46 +0000 (00:16 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 21 Jul 2011 22:16:46 +0000 (00:16 +0200)
* 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>.

14 files changed:
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

index 91abaf5..606b9fe 100644 (file)
--- 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
index 25dee3f..f0d8cfa 100644 (file)
@@ -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 @@ AC_DEFUN([gl_FUNC_FDOPENDIR],
 #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);
index 63fcb1a..2e8c681 100644 (file)
@@ -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 @@ AC_DEFUN([gl_FUNC_FREXPL_WORKS],
 # 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;
index 20a6226..4fecfb2 100644 (file)
@@ -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 @@ AC_DEFUN([gl_GETADDRINFO],
 #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
index 9e93fc9..542e4ce 100644 (file)
@@ -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_DEFUN([gl_FUNC_GETDOMAINNAME],
        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 @@ AC_DEFUN([gl_FUNC_GETDOMAINNAME],
               #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'])
index ad15c98..eb67444 100644 (file)
@@ -1,4 +1,4 @@
-#serial 10
+#serial 11
 
 # Copyright (C) 2005-2007, 2009-2011 Free Software Foundation, Inc.
 #
@@ -50,7 +50,11 @@ changequote([,])dnl
 #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)
index e799600..a1db8fc 100644 (file)
@@ -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_DEFUN([gl_FUNC_IOCTL],
       [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])
index 2f4cf4b..76101f3 100644 (file)
@@ -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_DEFUN([gl_FUNC_LDEXPL_WORKS],
       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;
index 855d5ec..972d38f 100644 (file)
@@ -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 @@ AC_DEFUN([gl_FUNC_LOGB],
          # 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 @@ AC_DEFUN([gl_FUNC_LOGB],
            # 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"])
index 72beaed..714d539 100644 (file)
@@ -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 test -z "$ac_list_mounted_fs"; then
 #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])
index 9c9b77b..7862710 100644 (file)
@@ -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 @@ AC_DEFUN([gl_FUNC_STPNCPY],
 #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 ()
 {
index f6aceff..0c5cc69 100644 (file)
@@ -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 @@ changequote([,])dnl
                [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] = "^";
index 969e319..e1ac20b 100644 (file)
@@ -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_DEFUN([gl_FUNC_STRNDUP],
          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);
index f7fd18a..b1914fb 100644 (file)
@@ -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_DEFUN([gl_HEADER_SYS_SELECT],
              [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);
                 ]])