Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unusual function pointer parameter syntax

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.

like image 480
user3126358 Avatar asked Nov 01 '22 08:11

user3126358


1 Answers

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.

like image 187
newacct Avatar answered Dec 03 '22 16:12

newacct