C++ is only used for tests, and some of the internal declarations are
not C++-safe. Rather than playing whack-a-mole with problems, just
turn on _ISOMAC mode for all C++ code.
It might well make sense to enable _ISOMAC for all IS_IN (nonlib) code
and/or to suppress most of libc-symbols.h itself in that mode, but when
I tried that, lots of stuff broke. This is safe in the present state
of the tree.
zw
* include/libc-symbols.h: Define _ISOMAC when __cplusplus is defined.
* include/errno.h, include/stdio.h, include/stdlib.h
* include/time.h, include/unistd.h, include/wchar.h: No need to
check __cplusplus nor use __BEGIN_DECLS/__END_DECLS.
---
include/errno.h | 2 +-
include/libc-symbols.h | 9 +++++++++
include/stdio.h | 5 -----
include/stdlib.h | 4 ----
include/time.h | 4 ----
include/unistd.h | 3 ---
include/wchar.h | 2 --
7 files changed, 10 insertions(+), 19 deletions(-)
@@ -2,7 +2,7 @@
#include <stdlib/errno.h>
-#if defined _ERRNO_H && !defined _ISOMAC && !defined __cplusplus
+#if defined _ERRNO_H && !defined _ISOMAC
# if IS_IN (rtld)
# include <dl-sysdep.h>
@@ -76,6 +76,15 @@
#define HAVE_ISWCTYPE 1
#define ENABLE_NLS 1
+/* As C++ is only used in tests, and the internal-use declarations
+ found in wrapper headers in include/ are not always C++-safe,
+ instruct those headers not to provide any of those declarations
+ when compiling C++. */
+
+#ifdef __cplusplus
+# define _ISOMAC 1
+#endif
+
/* The symbols in all the user (non-_) macros are C symbols. */
#ifndef __SYMBOL_PREFIX
@@ -5,7 +5,6 @@
# include <libio/stdio.h>
/* Now define the internal interfaces. */
-__BEGIN_DECLS
extern int __fcloseall (void);
extern int __snprintf (char *__restrict __s, size_t __maxlen,
@@ -30,7 +29,6 @@ extern int __vsscanf (const char *__restrict __s,
_G_va_list __arg)
__attribute__ ((__format__ (__scanf__, 2, 0)));
-# ifndef __cplusplus
extern int __sprintf_chk (char *, int, size_t, const char *, ...) __THROW;
extern int __snprintf_chk (char *, size_t, int, size_t, const char *, ...)
__THROW;
@@ -52,7 +50,6 @@ extern int __obstack_printf_chk (struct obstack *, int, const char *, ...)
__THROW;
extern int __obstack_vprintf_chk (struct obstack *, int, const char *,
_G_va_list) __THROW;
-# endif
extern int __isoc99_fscanf (FILE *__restrict __stream,
const char *__restrict __format, ...) __wur;
@@ -202,7 +199,5 @@ gets (char *__str)
extern FILE * __fmemopen (void *buf, size_t len, const char *mode);
libc_hidden_proto (__fmemopen)
-__END_DECLS
# endif
-
#endif
@@ -13,8 +13,6 @@
#if !defined __Need_M_And_C && !defined _ISOMAC
# include <sys/stat.h>
-__BEGIN_DECLS
-
extern __typeof (strtol_l) __strtol_l;
extern __typeof (strtoul_l) __strtoul_l;
extern __typeof (strtoll_l) __strtoll_l;
@@ -265,8 +263,6 @@ extern __typeof (unsetenv) unsetenv attribute_hidden;
extern __typeof (__strtoul_internal) __strtoul_internal attribute_hidden;
# endif
-__END_DECLS
-
#endif
#undef __Need_M_And_C
@@ -4,8 +4,6 @@
#ifndef _ISOMAC
# include <xlocale.h>
-__BEGIN_DECLS
-
extern __typeof (strftime_l) __strftime_l;
libc_hidden_proto (__strftime_l)
extern __typeof (strptime_l) __strptime_l;
@@ -112,7 +110,5 @@ extern double __difftime (time_t time1, time_t time0);
actual clock ID. */
#define CLOCK_IDFIELD_SIZE 3
-__END_DECLS
-
#endif
#endif
@@ -2,7 +2,6 @@
# include <posix/unistd.h>
# ifndef _ISOMAC
-__BEGIN_DECLS
libc_hidden_proto (_exit, __noreturn__)
rtld_hidden_proto (_exit, __noreturn__)
@@ -188,7 +187,5 @@ extern int __getlogin_r_loginuid (char *name, size_t namesize)
extern __typeof (__access) __access_noerrno attribute_hidden;
# endif
-__END_DECLS
# endif
-
#endif
@@ -172,7 +172,6 @@ extern int __vfwprintf (__FILE *__restrict __s,
const wchar_t *__restrict __format,
__gnuc_va_list __arg)
/* __attribute__ ((__format__ (__wprintf__, 2, 0))) */;
-#ifndef __cplusplus
extern int __vfwprintf_chk (FILE *__restrict __s, int __flag,
const wchar_t *__restrict __format,
__gnuc_va_list __arg)
@@ -184,7 +183,6 @@ extern int __vswprintf_chk (wchar_t *__restrict __s, size_t __n,
/* __attribute__ ((__format__ (__wprintf__, 5, 0))) */;
libc_hidden_proto (__vfwprintf_chk)
libc_hidden_proto (__vswprintf_chk)
-#endif
extern int __isoc99_fwscanf (__FILE *__restrict __stream,
const wchar_t *__restrict __format, ...);