Reputation: 5306
(Sorry this is a sample quiz can't use typedef:P) I'm trying to write a declaration for the following function:
A function:
Accepts a pointer points to a function accepts a pointer to int and returns a pointer to int.
Returns a pointer to a function accepts int and returns int.
Here is my code:
int (* sigal(int *(*f)(int *)))(int);
However, this is a syntactical error. What's the right way to write it?
Edited:
The error seems to be there shouldn't be an f
. I tried both my original code and
int (* sigal(int *(*)(int *)))(int);
on http://www.cdecl.org/. The later is passed.
Any explanation on what's the problem?
Update:
As 2501 said, the error seems to be a flavor of parser.
Upvotes: 2
Views: 49
Reputation: 25752
The correct way to write that is to use a typedef:
typedef int*(*fp)(int*);
typedef int(*fi)(int);
fi function(fp p);
The correct way to write this without typedef is:
int ( *( function( int*(*p)(int*) ) ) )(int);
Upvotes: 5