Mail Archives: djgpp/2000/01/20/10:29:26
sam <samirw AT connection DOT com> wrote:
[...]
> So who can tell me how to name my functions so that I can write C++ code
> and libraries.
Your problem, most probably, is not with C++ itself, or the names of
your functions. It's with *mixing* C and C++ parts (C library, C++
main program) in the same program.
> I have stumbled across the term 'name mangling'???
That's exactly your problem, I suspect. C++ adds information to the
names of objects (variables, functions) to carry type information, for
things like polymorphism, i.e. a function
int dosomething(double arg1, char *arg2);
may become the following linker-visible symbol:
.globl dosomething__FdPc
C doesn't do that, so the same function would be compiled to
.globl dosomething_
and that's it. To avoid this, you have to *tell* the C++ compiler that
an external function declaration (prototype in a header) is for a
C, not a C++ function.
extern "C" {
/* C declarations here */
}
does that for you. Read up the details in Stroustrup or some other C++
textbook.
--
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.
- Raw text -