I'm writing my own libraries in c++ and got stuck trying to define the callbacks for a few network events. I've been trying to find ways around it but no luck so far.
Normally in C you would do:
void onConnected(void *args){...}
void connect(){
struct espconn *conn = (struct espconn *) os_zalloc(sizeof(struct espconn));
// ...
espconn_regist_connectcb(conn, (espconn_connect_callback) onConnected);
}
But since my callback is a member function I'm obviously getting a compilation error (error: converting from 'void (FooClass::*)(void*)' to 'espconn_connect_callback {aka void (*)(void*)}')
Is there any c++ expert out there that could throw some light on this? I basically need the following (or similar) to work:
void FooClass::onConnected(void *args){...}
void FooClass::connect(){
struct espconn *conn = (struct espconn *) os_zalloc(sizeof(struct espconn));
// ...
espconn_regist_connectcb(conn, (espconn_connect_callback) onConnected);
}
Any help would be greatly appreciated!
A.