Hello everyone.
I am using a C library from C++ code. The C library declares some function pointers using typedef, and then makes some variables using this function pointer as the type. Like:
-
typedef void (*func) (int);
-
//then the pointer...
-
func ptr;
-
For me to work with this library I need to assign one of my member functions to the library variable(the func pointer) above.
My member function's declaration is similar to the C, but it's not static nor global(I don't want to make it so).
I take the address of the member function Inside my constructor like:
-
class Mine{
-
public:
-
Mine(){ func = &Mine::myfunc;} //This won't work!
-
void myfunc(int i){}
-
}
-
but I can't assign it to the C func pointer variable (declared in the library header). The compiler complains about the types being different. Am using g++ on mingw/windows.
Is there a way out or do I have to use some other technique?
Regards,
Alex.