I use an API which the declaration is:
some_API.h
typedef void (CALLBACK *EventCallback)();
class some_API{
public:
// ...
void EnableInterrupt(EventCallback func1, EventCallback func2);
// ...
};
and on the other side I have a class that use this API:
My_class.h
class My_class
{
some_API API;
void CALLBACK my_func() { cout << "This is my_func!\n" }
public:
void using_api()
{
API.EnableInterrupt(my_func, nullptr);
}
};
main problem is type of my_func, error:
Error (active) E0167 argument of type "void (__stdcall My_class::*)()" is incompatible with parameter of type "EventCallback"
I found this answer, but the problem is, the API is close source, so I can't change the declaration of the void EnableInterrupt(EventCallback, EventCallback)
.
Also I don't want to declare My_class::using_API
and My_class::API
as static member.
I want something similar to this:
API.EnableInterrupt((static_cast<void*>(my_func)), nullptr);
// or
API.EnableInterrupt((static_cast<EventCallback>(my_func)), nullptr); // invalid type conversion
Is there any way to cast that member function to a non-member function to pass it to some_API::EnableInterrupt(...)
?