Patchwork Allow Tru64 UNIX bootstrap with C++

login
register
mail settings
Submitter Rainer Orth
Date July 22, 2011, 6:23 p.m.
Message ID <yddwrfagooj.fsf@manam.CeBiTec.Uni-Bielefeld.DE>
Download mbox | patch
Permalink /patch/106376/
State New
Headers show

Comments

Rainer Orth - July 22, 2011, 6:23 p.m.
Ian,

> I agree with Joseph that this is wrong.  We must never wrap the #include
> of a system header file with extern "C".  That will simply break on some
> systems.  You should only wrap extern "C" around the various HAVE_DECL
> declarations.

ok, the following patch does this.  Bootstrap on alpha-dec-osf5.1b and
mips-sgi-irix6.5 is into stage3.

Ok for mainline if it passes?

Thanks.
	Rainer


2011-07-21  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	gcc:
	* system.h [__cplusplus]: Wrap C function declarations in extern "C".

	include:
	* xregex.h (regoff_t): Define.
Ian Taylor - July 22, 2011, 7:16 p.m.
Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> writes:

> 2011-07-21  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
>
> 	gcc:
> 	* system.h [__cplusplus]: Wrap C function declarations in extern "C".
>
> 	include:
> 	* xregex.h (regoff_t): Define.

This is OK.

I'll preapprove a similar patch to libcpp/system.h if you want to take a
look at that.

Thanks.

Ian

Patch

diff --git a/gcc/system.h b/gcc/system.h
--- a/gcc/system.h
+++ b/gcc/system.h
@@ -90,6 +90,10 @@  along with GCC; see the file COPYING3.  
 #  define fputc(C, Stream) fputc_unlocked (C, Stream)
 # endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 # ifdef HAVE_CLEARERR_UNLOCKED
 #  undef clearerr
 #  define clearerr(Stream) clearerr_unlocked (Stream)
@@ -170,6 +174,10 @@  extern int fprintf_unlocked (FILE *, con
 #  endif
 # endif
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif
 
 /* ??? Glibc's fwrite/fread_unlocked macros cause
@@ -390,6 +398,10 @@  extern int errno;
    here.  These checks will be in the undefined state while configure
    is running so be careful to test "defined (HAVE_DECL_*)".  */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #if defined (HAVE_DECL_ATOF) && !HAVE_DECL_ATOF
 extern double atof (const char *);
 #endif
@@ -430,10 +442,18 @@  extern void *sbrk (int);
 extern char *strstr (const char *, const char *);
 #endif
 
+#ifdef __cplusplus
+}
+#endif
+
 #ifdef HAVE_MALLOC_H
 #include <malloc.h>
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #if defined (HAVE_DECL_MALLOC) && !HAVE_DECL_MALLOC
 extern void *malloc (size_t);
 #endif
@@ -446,6 +466,10 @@  extern void *calloc (size_t, size_t);
 extern void *realloc (void *, size_t);
 #endif
 
+#ifdef __cplusplus
+}
+#endif
+
 #ifdef HAVE_STDINT_H
 #include <stdint.h>
 #endif
@@ -454,6 +478,10 @@  extern void *realloc (void *, size_t);
 #include <inttypes.h>
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* If the system doesn't provide strsignal, we get it defined in
    libiberty but no declaration is supplied.  */
 #if !defined (HAVE_STRSIGNAL) \
@@ -493,6 +521,10 @@  extern int snprintf (char *, size_t, con
 extern int vsnprintf(char *, size_t, const char *, va_list);
 #endif
 
+#ifdef __cplusplus
+}
+#endif
+
 /* 1 if we have C99 designated initializers.  */
 #if !defined(HAVE_DESIGNATED_INITIALIZERS)
 #define HAVE_DESIGNATED_INITIALIZERS \
diff --git a/include/xregex.h b/include/xregex.h
--- a/include/xregex.h
+++ b/include/xregex.h
@@ -8,6 +8,7 @@ 
 #  define regexec xregexec
 #  define regcomp xregcomp
 #  define regerror xregerror
+#  define regoff_t xregoff_t
 #  define re_set_registers xre_set_registers
 #  define re_match_2 xre_match_2
 #  define re_match xre_match