From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26841 invoked by alias); 9 Aug 2014 20:28:21 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 26830 invoked by uid 89); 9 Aug 2014 20:28:20 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 X-HELO: da.nameserverus2.com Received: from da.nameserverus2.com (HELO da.nameserverus2.com) (86.111.247.88) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Sat, 09 Aug 2014 20:28:19 +0000 Received: from sir10000 by da.nameserverus2.com with local (Exim 4.83) (envelope-from ) id 1XGDFP-0000pw-Tm for gcc-help@gcc.gnu.org; Sat, 09 Aug 2014 22:28:15 +0200 Received: from 89.75.51.68 ([89.75.51.68]) by sirzooro.prohost.pl (Horde Framework) with HTTP; Sat, 09 Aug 2014 22:28:15 +0200 Date: Sat, 09 Aug 2014 20:28:00 -0000 Message-ID: <20140809222815.Horde.fi7naBAb0FA72H4icn4BOg1@sirzooro.prohost.pl> From: daniel@poradnik-webmastera.com To: gcc-help@gcc.gnu.org Subject: Re: C++ name mangling in C References: <20140809215057.Horde.vyEDuGF06pHW1H_WOtKpyw1@sirzooro.prohost.pl> In-Reply-To: User-Agent: Internet Messaging Program (IMP) H5 (6.2.1) Content-Type: text/plain; charset=UTF-8; format=flowed; DelSp=Yes MIME-Version: 1.0 Content-Disposition: inline X-SW-Source: 2014-08/txt/msg00073.txt.bz2 Cytowanie Marc Glisse : >> Therefore I was looking for a way to detect such bugs with some >> tool. I thought about forcing C++ mangling when compiling C code, >> but looks that gcc does not have any command line option to this. >> Please correct me if I am wrong. >> >> If there is no such option, I would like to open an enhancement to >> add it. I thought about it for some time and looks that this new >> option should do 3 things: enable C++ name mangling, enable extern >> "C" directive and define the __cplusplus macro. Any comments on >> this proposal is also welcome. > > How about compiling your code with g++ then? (possibly add > -fpermissive to accept more C-isms) I already tried, and got error on some typedef struct declaration (do not remember exact syntax now). I will try to add -fpermissive and see if it will help. > If you define __cplusplus, you'll need a C++ compiler anyway because > the headers will contain C++ code. I see. In my case this is needed mostly for C stdlib. Other 3rd party libs usually have C and C++ interface separated, so simple support for extern "C" would be enough. Another option to use instead of defining __cplusplus is to generate C names for functions defined in system headers (including ones from paths specified with -isystem). But this seems to be more complex, probably some extra interaction between preprocessor and compiler would be needed. > Compiling with -flto may also generate interesting messages. Will give it a try too. -- Regards, Daniel