I want to call the following function and pass it a function with a parameter. The purpose of that is that it should call the function with my specified parameter so I know what triggered the function (in that case a gpio pin on the Raspberry Pi).
int wiringPiISR( int pin, int edgeType, void (*function)( void ) );
Currently I have:
for ( int i = 0; i < myValues.size(); ++i )
{
int myValue = myValues[ i ];
wiringPiISR( myValue, INT_EDGE_RISING, &myCallback( myValue ) );
}
Though this is giving me the following error:
error: lvalue required as unary ‘&’ operand
Which I can't really understand as to my understanding, myValue is an lvalue or is it not?
Is it what I want do even possible? If so how? The function wiringPiISR is from a library called wiringPi and I would like to avoid modifying it as much as possible.
&myCallback(myValue))is the same as&(myCallback(myValue)))so you are taking the address on the return value ofmyCallback. sincemyValueis already the first parameter, you may only need to pass&myCallback. But we can't tell from the current context.