C++ Function Callbacks: Cannot convert from a member function to a function signature

You’re trying to pass a member function pointer as a normal function pointer which won’t work. Member functions have to have the this pointer as one of the hidden parameters, which isn’t the case for normal functions, so their types are incompatible.

You can:

  1. Change the type of your argument to accept member functions and also accept an instance to be the invoking object
  2. Quit trying to pass a member function and pass a normal function (perhaps by making the function static)
  3. Have a normal function that takes an instance of your class, a member function pointer, and a std::string and use something like boost’s bind to bind the first two arguments
  4. Make the callback registration function accept a functor object, or an std::function (I think that’s the name)
  5. Numerous other ways which I won’t detail here, but you get the drift.

Leave a Comment