0

I am writing C++ code which calls sasl_client_init(). I defined plugin functions such as:

int GetPluginPath(void *context,
  const char **path) {

However, the compiler doesn't allow me to assign function pointer to proc member of sasl_callback_t :

connection/connection-factory.cc:164:22: error: reinterpret_cast from 'int (SaslHandler::*)(void *, int, const char )' to 'sasl_callback_ft' (aka 'int ()()') is not allowed

callback->proc = reinterpret_cast<sasl_callback_ft> (&SaslHandler::SaslLogFn);

Any hint how sasl_callback_t should be initialized ?

Thanks

Ted
  • 379
  • 1
  • 5
  • 18
  • Possible duplicate of: http://stackoverflow.com/questions/400257/how-can-i-pass-a-class-member-function-as-a-callback – πάντα ῥεῖ Mar 04 '17 at 19:20
  • Partly but it's not even the same argument signature. – Kurt Stutsman Mar 04 '17 at 19:27
  • Background: more than one function pointer is passed in sasl_callback_t array to sasl_client_init(). Here is one more function to be passed: int SaslLogFn(void *context __attribute__((unused)), int priority, const char *message) { Here is declaration of sasl_callback_t : typedef struct sasl_callback { unsigned long id; int (*proc)(void); /* Callback function. Types of arguments vary by 'id' */ void *context; } sasl_callback_t; – Ted Mar 04 '17 at 20:36
  • Pardon for the formatting. See http://pastebin.com/EitMw5Jt – Ted Mar 04 '17 at 22:13

0 Answers0