How do I call a C-function with a Functor that expects a pointer to a void function in C++?

I'd like to wrap (`Facade Pattern`) Allegro's use of threads i.e. `install_int_ex(void (__cdecl*)(void), int tick);` and `remove_int(void (__cdecl*)(void))` with a class I wrote that uses templates and `user-defined Functor Objects` to install interrupts and remove interrupts when the class is created and destroyed. I keep getting compiler errors: `error C2664: 'install_int_ex' : cannot convert parameter 1 from 'void (__thiscall [User-defined FunctorName Here]::* )(void)' to 'void (__cdecl *)(void)'` and similar for `remove_int(void (__cdecl*)(void))` [This seems to work *provided the called function accepts pointers to `void*`user data*][1] Unfortunately, Allegro is not this flexible. Is there a way around this limitation or am I going to have to use Windows's `CreateThread` (and learn threading "the real way" in the process)? See Also: [Using a C++ Member Function as the Thread's Entry-Point-Function][2] [1]: https://stackoverflow.com/questions/7140042/c-functor-as-a-function-pointer [2]: http://www.computersciencelab.com/MultithreadingTut1.htm
You can't pass non-static member functions as c style functions. Try making the function static.

以上就是How do I call a C-function with a Functor that expects a pointer to a void function in C++?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » CSS3 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏