vendredi 23 janvier 2015

Passing member function pointer to the c-style function

I am trying to pass member function pointer to the c-style function (as it's lib in C)


The pointer it wants is defined as:



void (*)(int, const char*)


So the function I am trying to pass is:



void Application::onError(int error, const char *description)


I am trying to pass that with this code:



setCallback(bind(&Game::onError, this, placeholders::_1, placeholders::_2));


This gives me following error:



cannot convert ‘std::_Bind_helper<false, void (Application::*)(Application*, int,
const char*), Application* const, const std::_Placeholder<1>&, const
std::_Placeholder<2>&>::type {aka std::_Bind<std::_Mem_fn<void (Application::*)
(Application*, int, const char*)>(Application*, std::_Placeholder<1>,
std::_Placeholder<2>)>}’ to ‘GLFWerrorfun {aka void (*)(int, const char*)}’ for
argument ‘1’ to ‘void (* glfwSetErrorCallback(GLFWerrorfun))(int, const char*)’
glfwSetErrorCallback(bind(&Application::onError, this, placeholders::_1, placeholders::_2));


Is there any way to successfully pass member function as binded function to the c-style function?


Thanks


Aucun commentaire:

Enregistrer un commentaire