From: Bruno Haible Date: Thu, 21 Jul 2011 22:16:46 +0000 (+0200) Subject: Declare system functions in a way that works with C++. X-Git-Tag: v0.1~2088 X-Git-Url: http://erislabs.net/gitweb/?a=commitdiff_plain;h=6195fa324fac1442ba68395a30f32110997959dd;p=gnulib.git 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 . --- diff --git a/ChangeLog b/ChangeLog index 91abaf5da..606b9fe13 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,34 @@ +2011-07-21 Bruno Haible + + 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 . + 2011-07-12 Jim Meyering maint.mk: prohibit inclusion of "verify.h" without use diff --git a/m4/fdopendir.m4 b/m4/fdopendir.m4 index 25dee3fc4..f0d8cfa67 100644 --- 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 @@ AC_DEFUN([gl_FUNC_FDOPENDIR], #include #include #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); diff --git a/m4/frexpl.m4 b/m4/frexpl.m4 index 63fcb1a8b..2e8c68136 100644 --- 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 @@ 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; diff --git a/m4/getaddrinfo.m4 b/m4/getaddrinfo.m4 index 20a622611..4fecfb2fa 100644 --- 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 @@ AC_DEFUN([gl_GETADDRINFO], #include #endif #include -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 diff --git a/m4/getdomainname.m4 b/m4/getdomainname.m4 index 9e93fc93c..542e4cead 100644 --- 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_DEFUN([gl_FUNC_GETDOMAINNAME], AC_LINK_IFELSE( [AC_LANG_PROGRAM( [[#include - 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 #endif #include - 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']) diff --git a/m4/getlogin_r.m4 b/m4/getlogin_r.m4 index ad15c9879..eb6744481 100644 --- 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 @@ changequote([,])dnl #include #include #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) diff --git a/m4/ioctl.m4 b/m4/ioctl.m4 index e799600f9..a1db8fc09 100644 --- 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_DEFUN([gl_FUNC_IOCTL], [AC_COMPILE_IFELSE( [AC_LANG_PROGRAM( [[#include ]], - [[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]) diff --git a/m4/ldexpl.m4 b/m4/ldexpl.m4 index 2f4cf4b89..76101f336 100644 --- 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_DEFUN([gl_FUNC_LDEXPL_WORKS], AC_RUN_IFELSE( [AC_LANG_SOURCE([[ #include -extern long double ldexpl (long double, int); +extern +#ifdef __cplusplus +"C" +#endif +long double ldexpl (long double, int); int main() { int result = 0; diff --git a/m4/logb.m4 b/m4/logb.m4 index 855d5ec2c..972d38f7c 100644 --- 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 @@ AC_DEFUN([gl_FUNC_LOGB], # define __NO_MATH_INLINES 1 /* for glibc */ #endif #include - 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 - extern double logb (double x); + extern + #ifdef __cplusplus + "C" + #endif + double logb (double x); double x;]], [[x = logb(x);]])], [LOGB_LIBM="-lm"]) diff --git a/m4/ls-mntd-fs.m4 b/m4/ls-mntd-fs.m4 index 72beaed9a..714d539bf 100644 --- 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 test -z "$ac_list_mounted_fs"; then #if HAVE_SYS_STATVFS_H # include #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]) diff --git a/m4/stpncpy.m4 b/m4/stpncpy.m4 index 9c9b77be4..78627108b 100644 --- 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 @@ AC_DEFUN([gl_FUNC_STPNCPY], #include /* for strcpy */ /* The stpncpy prototype is missing in 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 () { diff --git a/m4/strerror_r.m4 b/m4/strerror_r.m4 index f6aceff64..0c5cc6968 100644 --- 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 @@ changequote([,])dnl [AC_LANG_PROGRAM( [[#include #include - 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] = "^"; diff --git a/m4/strndup.m4 b/m4/strndup.m4 index 969e3191a..e1ac20b8a 100644 --- 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_DEFUN([gl_FUNC_STRNDUP], AC_LANG_PROGRAM([[#include #include ]], [[ #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); diff --git a/m4/sys_select_h.m4 b/m4/sys_select_h.m4 index f7fd18aab..b1914fb80 100644 --- 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_DEFUN([gl_HEADER_SYS_SELECT], [AC_LANG_PROGRAM([[#include ]], [[ #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); ]])