Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Saib

Howto retrieve a member function's address?

This topic is 5837 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m writing a function pointer that can deal with any number of arguments as well as any calling convention (which includes __thiscall), while it is important that every such pointer is of the same type, i.e. that the class is not templatized. Casting, for whatever reason, does not work (not even reinterpret_cast), so I thought I''ll try to cheat with ASM, like so:
  
template <typename _ret, classname _class, typename _arg0>
void FuncPtr::PointToFunc (_ret (_class::* funcAddr)(_arg0) /*...*/)
{
    void* addr; // somehow need to cheat funcAddr to void*


    _asm
    {
        mov     addr, funcAddr // causes C2415, improper operand type
    }



    /*...*/
}
  
I''m aware that I would have to clone this function for every number of arguments a member function might have, but I could live with that. Does anyone know how to fix the above code? Another way of getting to know a member function''s address (it is in memory only once (hence the "this" pointer) so it must be possible) would of course be as much appreciated. Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
Ah, I planned to look at the boost library some time soon anyway.

Thanks for the hint

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!