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*]
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]
: 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前端其它相关文章！