This is the mail archive of the crossgcc@cygnus.com mailing list for the crossgcc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: gcc vs g++ and linking with as


> But none of it is C++ code.  It's all C or assembler.
> Shouldn't gcc and g++ compile a *.c file the same way?
> 
No, gcc and g++ shells are almost alike but g++ always assumes that the
source is c++ rather than examining the extension to make that
determination.

> Also, we have calls going both ways  c-->asm()  asm-->c()
> 
> Sounds like name mangling will make asm-->c++() impossible (?)
> 
Its not impossible. You need to either know what the mangled name is to
invoke the routine (not recommended because it changes) or you need to
create the routine with C++ name mangling (using the C++ extern "C" stuff). 

Turning off name mangling for a particular function will prevent you from
overloading that function. 

You are treading on dangerous ground if you attempt to call member functions
of C++ objects because you will need to know the internals of how the "this"
pointer is passed around, etc..

Gary

> Dave Hansen wrote:
> > 
> > This is the name mangling that g++ uses to resolve overloaded functions.
> > To prevent this, declare the assembly functions as extern "C" in the
> > C++ code.  For example:
> > 
> >    extern "C" asm_fn();
> > 
> > HTH.  Regards,
> > 
> >      -=Dave
> > 
> > >>> Chris Howard <choward@intellistor.com> 06/25/98 10:29AM >>>
> > binutils 2.9
> > gcc/g++ 2.8.0
> > 
> > Host Sun Sparc Solaris 2.5
> > Target Motorola Coldfire (-m5200)  a.out object format
> > 
> > ---
> > 
> > Not using stdlib  (-nostdlib)
> > 
> > We have some code in assembler, and some in C.
> > Compiling with as,gcc and linking with ld works fine.
> > Compiling with as,g++ and linking with ld does not work,
> >   undefined symbols for those things written in assembler.
> > 
> > The .o files output from g++ compilation have exported symbols that
> > end in '__Fv' whereas the assembler output .o files don't have
> > '__Fv' on the symbols.  Is that the problem?  Is there
> > some way to make it work?  What is __Fv?
> > 
> > An alternative might be to put the assembly code in
> > C/C++ wrapper functions.  Any hints/comments that
> > would be appreciated also.
> > 
> > --
> > Chris Howard            Fujitsu Computer Products of America
> >                                           Longmont, Colorado
> >
> 
> 
> -- 
> Chris Howard            Fujitsu Computer Products of America
>                                           Longmont, Colorado