www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/04/25/23:04:09

From: apsh AT ecr DOT mu DOT oz DOT au (Alistair_P SHILTON)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: selectively turning off function name mangling in C++
Date: 26 Apr 2001 02:44:03 GMT
Organization: Computer Science, University of Melbourne
Lines: 51
Message-ID: <9c821j$l2g$1@mulga.cs.mu.OZ.AU>
References: <9c5o5s$fvc$1 AT mulga DOT cs DOT mu DOT OZ DOT AU> <9c6a4m$2bv$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE>
NNTP-Posting-Host: gromit.ecr.mu.oz.au
X-Trace: mulga.cs.mu.OZ.AU 988253043 21584 128.250.61.61 (26 Apr 2001 02:44:03 GMT)
X-Complaints-To: usenet AT cs DOT mu DOT OZ DOT AU
NNTP-Posting-Date: 26 Apr 2001 02:44:03 GMT
X-Newsreader: TIN [version 1.2 PL2]
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Thanks people - code now working fine.

Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) wrote:
: Alistair_P SHILTON <apsh AT ecr DOT mu DOT oz DOT au> wrote:
: > I was wondering if it is possible to tell gxx to not mangle the names of
: > certain functions?  I've been trying to interface some of my C++ code with
: > some fortran code I downloaded of the net.  g77 mangles its function names
: > by adding _'s to start and finish (so foo becomes _foo_).  

: Careful, there --- that's not the only effect. Fortran also adds
: invisible parameters for multidimensional variable-sized array
: arguments, and it passes all arguments by reference.  It also treats
: strings in a wildly different way than the NUL-terminated variety used
: by C and C++.

Thats ok - I'm only passing ints and doubles.  Just a simple hack interface
to avoid dumping 40M to disk whenever I call the fortran stuff.

: You may want to get your hands on the 'cfortran.h' package to help you
: get around these pitfalls, while still keeping your own source code as
: portable as possible.

: > But gxx mangles the same function to _foo__*** (*** = annoying junk)
: > - which stops the .o files from linking correctly!

: Learn about the 

: 	extern "C"

: qualifier of C++.  Note that even this won't let you blindly call C++
: methods from Fortran: the "this" pointer will be missing, and it's
: hard to find out when and how to add it in manually.

: Calling other language functions from C++ is rather simple as long as
: they have a C-compatible calling interface available. Calling C++
: methods from other languages can be close to impossible without
: extensive knowledge about internal C++ compiler details.

: -- 
: Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
: Even if all the snow were burnt, ashes would remain.

--
----------------------------------------------------

Regards

Alistair Shilton

http://www.ee.mu.oz.au/pgrad/apsh/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019