|
From: Clive M. <Cli...@ms...> - 2009-09-12 04:58:08
|
My project is almost entirely C code but I need to add on a couple of C++
modules (one is the freetype-6 library). In similar circumstances, with my
previous compiler, I just marked the interface wrapper-module's cpp file
with C code tucked inside the usual: #ifdef __cpluplus extern "C" {
... } stuff and slapped it in a cpp file and off it went.
I need to use g++ now, and somehow it doesn't grasp that a C file (called,
for example my_hello_world_file.c) should have an object file with just
plain C symbols. According to the g++ help the -x option, with nothing
specified, should set g++ to figure things out as best it can and that this
is also the default. My guess was that g++ would then emit a object file
with regular C symbols. I tried to build my code with g++ changing nothing.
I did this before I began the task of integrating a C++ module to keep
things simple (change only one thing at a time). It doesn't link -- none of
the inter-file symbols line up.
I can see that the linker doesn't mind the g++ symbols when the source code
has the extern "C" stuff and g++ dutifully make the symbols right.
I'm reluctant to patch-up each C code file and the header files just to add
a couple of C++ modules to make things kosher with g++. The IDE I'm using
doesn't have provision for using a different compiler for each source file.
I could build an independent module just to get it all to play and then peel
the C++ modules into a separate library with just a C interface... but that's
even more work.
There has to be an easier way and I just don't see it. Advice please?
Clive McCarthy.
|