This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: C++ name mangling in C
- From: daniel at poradnik-webmastera dot com
- To: gcc-help at gcc dot gnu dot org
- Date: Sat, 09 Aug 2014 22:28:15 +0200
- Subject: Re: C++ name mangling in C
- Authentication-results: sourceware.org; auth=none
- References: <20140809215057 dot Horde dot vyEDuGF06pHW1H_WOtKpyw1 at sirzooro dot prohost dot pl> <alpine dot DEB dot 2 dot 11 dot 1408092157400 dot 10998 at stedding dot saclay dot inria dot fr>
Cytowanie Marc Glisse <marc.glisse@inria.fr>:
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