Important: Please read the Qt Code of Conduct -

How to connect a C function into a class ( int wiringPiISR (int pin, int mode, void (*function)(void)) )

  • Hello ,

    I'm using WiringPi librairy with my Raspberry Pi 3

    I have a class Form_Trigger_Laser

    My function to connect my interrupt from WiringPi

    void Form_Trigger_Laser::InitWiringPiLaser()



    void Form_Trigger_Laser::Edge_Falling_Laser()

    Nevertheless, the prototype of wiringPiISR is :
    int wiringPiISR (int pin, int mode, void (*function)(void))

    I can't connect at my function Class ...
    How to connect : int wiringPiISR (int pin, int mode, void (*function)(void)) at Form_Trigger_Laser::Edge_Falling_Laser() ?

    Thank you
    Best regard

  • Lifetime Qt Champion

    From Very fast look it seems like it wants a good old plain c call back?

    void (*function)(void)

    So you must use a global function or a static class function for it to like it.

    The function must be

    void FuncName(void)

    So no return or parameter.

    so void Form_Trigger_Laser::InitWiringPiLaser()
    cannot be part of class. ( or must be static )

  • Hello MRJJ,
    You are fast;)

    It's working , top :)

Log in to reply