[comp.lang.c++] cfront name mangling

matt@emtek.UUCP (Matt Meola) (07/13/90)

Does anyone know why cfront mangles the name catch_sig(int) into
catch_sig__FiPFve_v ?  My code compiles fine, but the loader (ld)
complains about not knowing about the name catch_sig__FiPFve_v.
Any ideas?

geoff@circus.camex.com (Geoffrey Knauth) (07/13/90)

In article <140@emtek.UUCP> matt@emtek.UUCP (Matt Meola) writes:
>
>Does anyone know why cfront mangles the name catch_sig(int) into
>catch_sig__FiPFve_v ?  My code compiles fine, but the loader (ld)
>complains about not knowing about the name catch_sig__FiPFve_v.
>Any ideas?

I believe the extra characters type-encode the function and provide it
a signature (for the linker's benefit).  See section 7.2.1c (p. 122)
of the Annotated C++ Reference Manual by Ellis and Stroustrup.

My initial parse of FiPFve_v is: F - global function, i - 1st arg
"int", P - pointer, F - function, v - "void", e - "...", _v - dunno.
I'm sure someone else can interpret this more intelligently.
Geoffrey S. Knauth                 		      geoff@camex.com
Camex, Inc., 75 Kneeland St.			      geoff%camex@uunet.uu.net
Boston, MA 02111, (617) 426-3577 x451		      standard disclaimers

raeburn@athena.mit.edu (Ken Raeburn) (07/13/90)

In article <140@emtek.UUCP> matt@emtek.UUCP (Matt Meola) writes:
>
>Does anyone know why cfront mangles the name catch_sig(int) into
>catch_sig__FiPFve_v ?  My code compiles fine, but the loader (ld)
>complains about not knowing about the name catch_sig__FiPFve_v.
>Any ideas?

This is done to permit function overloading based on argument types.
The ugly string tacked on the end is a compact description of the
argument list that the function accepts.  Hence, if you have

	int min (int, int)
	double min (double, double)

then two different functions names will be used at the
C/assembler/linker levels, both starting with "min__" but ending with
different strings.

If you are trying to link to C code (which I presume is the case since
you say catch_sig__FiPFve_v isn't known) try using

	extern "C" catch_sig (int);

to tell cfront that the function should be given C linkage (i.e., no
encoding of the argument types in the name).  (Um, I'm assuming you're
using cfront 2.0 here....)

If catch_sig(int) is a C++ function, make sure that your definition
and declarations agree on what the argument list looks like.
--
~~
~~ Ken Raeburn / raeburn@athena.mit.edu
~~ systems programmer
~~ MIT Project Athena