From patchwork Fri Jul 22 18:23:08 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rainer Orth X-Patchwork-Id: 106376 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id BF52EB6F68 for ; Sat, 23 Jul 2011 04:23:48 +1000 (EST) Received: (qmail 18545 invoked by alias); 22 Jul 2011 18:23:37 -0000 Received: (qmail 18529 invoked by uid 22791); 22 Jul 2011 18:23:35 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, TW_EG X-Spam-Check-By: sourceware.org Received: from snape.CeBiTec.Uni-Bielefeld.DE (HELO smtp-relay.CeBiTec.Uni-Bielefeld.DE) (129.70.160.84) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 22 Jul 2011 18:23:20 +0000 Received: from localhost (localhost.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTP id 1DBD3B99; Fri, 22 Jul 2011 20:23:19 +0200 (CEST) Received: from smtp-relay.CeBiTec.Uni-Bielefeld.DE ([127.0.0.1]) by localhost (malfoy.CeBiTec.Uni-Bielefeld.DE [127.0.0.1]) (amavisd-new, port 10024) with LMTP id MankoP22C8pJ; Fri, 22 Jul 2011 20:23:16 +0200 (CEST) Received: from manam.CeBiTec.Uni-Bielefeld.DE (manam.CeBiTec.Uni-Bielefeld.DE [129.70.161.120]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp-relay.CeBiTec.Uni-Bielefeld.DE (Postfix) with ESMTPS id 6D7BDB97; Fri, 22 Jul 2011 20:23:15 +0200 (CEST) Received: (from ro@localhost) by manam.CeBiTec.Uni-Bielefeld.DE (8.14.5+Sun/8.14.5/Submit) id p6MIN9JV003897; Fri, 22 Jul 2011 20:23:09 +0200 (MEST) From: Rainer Orth To: Ian Lance Taylor Cc: gcc-patches@gcc.gnu.org Subject: Re: Allow Tru64 UNIX bootstrap with C++ References: Date: Fri, 22 Jul 2011 20:23:08 +0200 In-Reply-To: (Ian Lance Taylor's message of "Thu, 21 Jul 2011 22:52:24 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (usg-unix-v) MIME-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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 gcc: * system.h [__cplusplus]: Wrap C function declarations in extern "C". include: * xregex.h (regoff_t): Define. 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 #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 #endif @@ -454,6 +478,10 @@ extern void *realloc (void *, size_t); #include #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