Mail Archives: djgpp/2001/04/25/03:02:31
On 25 Apr 2001, Alistair_P SHILTON wrote:
> I was wondering if it is possible to tell gxx to not mangle the names of
> certain functions?
That's what ``extern "C"'' is for.
> 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_). But gxx mangles
> the same function to _foo__*** (*** = annoying junk) - which stops the .o
> files from linking correctly!
When you call your Fortran functions from C++, use the g77-mangled name,
and declare a prototype for those functions with ``extern "C"''. For
example:
extern "C" double _foo_ (int *, double *);
...
double value = _foo_ (bar, baz);
- Raw text -