This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: calling a C++ member function


On Wed, Jun 13, 2012 at 8:51 AM, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
> On Jun 13, 2012 11:56 AM, "Xin Tong" wrote:
>>
>> Function pointers can be used to call functions in C. but for C++
>> member functions. A special function pointer needs to be used, i.e.
>>
>> float (SomeClass::*my_memfunc_ptr)(int, char *);
>>
>> but eventually, my_memfunc_ptr will hold the address of the code of
>> the function it points to. can i set up the calling context myself at
>> this point, i.e. put "this" pointer into rdi, put the arguments into
>> other registers/stacks and jump to the address held in the
>> my_memfunc_ptr. would this work in gcc compiled code , what about
>> other compilers and os linkages ?
>
> Have you seen http://gcc.gnu.org/onlinedocs/gcc/Bound-member-functions.html ?

Ok. did not know that before. it seems member functions are callable
with instruction address. especially with PMF enabled. one can take
the address without an object.

Thanks

Xin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]