delorie.com/archives/browse.cgi | search |
From: | Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de> |
Newsgroups: | comp.os.msdos.djgpp |
Subject: | Re: selectively turning off function name mangling in C++ |
Date: | 25 Apr 2001 10:49:58 GMT |
Organization: | Aachen University of Technology (RWTH) |
Lines: | 35 |
Message-ID: | <9c6a4m$2bv$1@nets3.rz.RWTH-Aachen.DE> |
References: | <9c5o5s$fvc$1 AT mulga DOT cs DOT mu DOT OZ DOT AU> |
NNTP-Posting-Host: | acp3bf.physik.rwth-aachen.de |
X-Trace: | nets3.rz.RWTH-Aachen.DE 988195798 2431 137.226.32.75 (25 Apr 2001 10:49:58 GMT) |
X-Complaints-To: | abuse AT rwth-aachen DOT de |
NNTP-Posting-Date: | 25 Apr 2001 10:49:58 GMT |
Originator: | broeker@ |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
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++. 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.
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |