Sender: nate AT cartsys DOT com Message-ID: <36856987.61BC22E6@cartsys.com> Date: Sat, 26 Dec 1998 14:56:07 -0800 From: Nate Eldredge X-Mailer: Mozilla 4.08 [en] (X11; I; Linux 2.0.35 i486) MIME-Version: 1.0 To: djgpp AT delorie DOT com Subject: Re: Calling C++ object member functions from assembly? References: <3SCgHd$QOw AT cszone DOT cc DOT ntu DOT edu DOT tw> Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Reply-To: djgpp AT delorie DOT com ªü­õ 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