0

I must cast a function pointer from a C++ class to hand over the function as parameter of a plain C function that only excpected pointers of void* and not Foo::void*.

Any ideas how to cast it?

   typedef void* (Foo::*from) (void*) ;
   typedef void* (*to)(void *);

The C++ function has the following signatur:

void* Foo::bar(void *ptr)

Best regards

501 - not implemented
  • 2,638
  • 4
  • 39
  • 74
  • 2
    Short answer: You can't. Member functions need an object to be called on, and you lose that interface with a function pointer. – NathanOliver Jul 08 '21 at 15:20
  • Thanks for the answer and the link to the similar question. Now I fixed it by using a static forwarding method that hast an objectpointer as parameter – 501 - not implemented Jul 09 '21 at 07:05

0 Answers0