www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/04/25/03:02:31

Date: Wed, 25 Apr 2001 09:30:44 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Alistair_P SHILTON <apsh AT ecr DOT mu DOT oz DOT au>
cc: djgpp AT delorie DOT com
Subject: Re: selectively turning off function name mangling in C++
In-Reply-To: <9c5o5s$fvc$1@mulga.cs.mu.OZ.AU>
Message-ID: <Pine.SUN.3.91.1010425092743.22758O-100000@is>
MIME-Version: 1.0
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

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 -


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