is there any difference between this two syntaxes?
void fun( void (*funptr)() )
{
funptr(); // calls the function
}
void fun( void funptr() )
{
funptr(); // calls the function
}
i'd always been using the first form, but i've just seen the second one and it seems it behaves exactly the same, while the syntax is clearer.
There is no difference. In both cases, funptr
has type void (*)()
, a function pointer type.
C99 standard, section 6.7.5.3, paragraph 8:
A declaration of a parameter as ‘‘function returning type’’ shall be adjusted to ‘‘pointer to function returning type’’, as in 6.3.2.1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With