Mail Archives: djgpp/1998/12/26/18:09:59
ªüõ wrote:
>
> How can we call a C++ member function from assembly?
>
> For example:
>
> In C++:
>
> class Merry {
> public:
> void CallMe();
> };
>
> Merry Xmas;
>
> In assembly:
>
> How to call Xmas.CallMe(); ?
There are two problems to be dealt with.
* Name mangling
In C++, names are mangled to encode the type of the symbol and allow
overloading. So it may be called `MerryCallMe__voidfn__void' or
something equally cryptic. You may have to look at the assembly to find
out what it is.
* Calling conventions
Member functions are often passed an invisible argument, which is (I
think) their `this'. I think it's the first argument under GCC, but may
be wrong. You'll have to pass it appropriately.
Can't you use the "C" attribute to specify C calling conventions and
naming, and write a wrapper function? Or does that only work for
external functions? I don't use C++ much.
--
Nate Eldredge
nate AT cartsys DOT com
- Raw text -