Mail Archives: djgpp/2001/04/25/23:04:09
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 -