Skip to content

Instantly share code, notes, and snippets.

@hartbit
Created August 1, 2013 15:28
Show Gist options
  • Save hartbit/6132428 to your computer and use it in GitHub Desktop.
Save hartbit/6132428 to your computer and use it in GitHub Desktop.
// From library
typedef void (*Callback) ( int nEvent, const char* sMessage );
void SetCallback( Callback * cbk );
// My code
void MyCallback(int nEvent, const char* sMessage) {
// ....
}
SetCallback(MyCallback);
// No matching function for call to 'SetCallback'
// Candidate function not viable: no known conversion from 'void (int, const char *)' to 'Callback *' (aka 'void (**)(int, const char *)') for 1st argument
SetCallback(&MyCallback);
// No matching function for call to 'SetCallback'
// Candidate function not viable: no known conversion from 'void (*)(int, const char *)' to 'Callback *' (aka 'void (**)(int, const char *)') for 1st argument
SetCallback(&&MyCallback);
// No matching function for call to 'SetCallback'
// Candidate function not viable: cannot convert argument of incomplete type 'void *' to 'Callback *' (aka 'void (**)(int, const char *)')
SetCallback((Callback*)MyCallback);
SetCallback((Callback*)&MyCallback);
SetCallback((Callback*)&&MyCallback);
// They all crash when the library tries to call my callback
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment