How do APIs callback to class members

Hello,

Again and again the same question but the answers I found, notably on Stackoverflow, give me headaches.

I think I found the solution here (http://www.cplusplus.com/forum/general/136410/), given by Disch (13767) and it's the reason why I used the same title for this topic and because the question has maybe not be precisely answered, at least for a noob like me.

What I want ot do?
I want to use a library providing a C Function defined like that:
 
int wiringPiISR(int, int, void (*function)(void));


And I have an application class with a member method defined like that:
 
void Input::interrupteEdge(); // This function CANNOT be static! 


And I would like to specify this member method to the C API function, notably in my Constructor like that:
1
2
3
Input::Input() {
    int status = wiringPiISR(1, 1, &Input::interrupteEdge);
}


And because I'm not sure about the syntax, I want, in my constructor, indicate to ``wiringPiISR()`` that it sould call the member belonging to THIS objet instance.

As I'm very new in C++, I see what's wrong with the proposed solution, but I don't see how I can solve my issue.

My problem here is that I want to use instance members in C API function (http://wiringpi.com/reference/priority-interrupts-and-threads/).

For the example, I rewrote these functions as fakes.

My code is here (http://cpp.sh/8ehg2 )
Last edited on
Topic archived. No new replies allowed.