"Chris Saunders" <chris.saunders@sympatico.ca> wrote
> I am attempting to write and interface from another language to
> some C code. I am having some difficulty interpreting a declaration.
>
> int (*foo(char *ctx))(int,long *);
>
> Any help would be appreciated.
>
> Regards
> Chris Saunders
> chris.saunders@sympatico.ca
>
Read the statement as follows:
1. Find out the name of the identifier. It is:
foo
2. See on it's right side. It has (char *ctx) on it's
right. An identifier followed by a left parantheses,
some declarations -- zero or more; and a right parantheses
is a declaration of a function. So,
" ... foo is a function taking as argument a pointer to
char ..."
3. Now, look at it's left side. It has an asterisk on it's left;
a probable sign of either poiter to a function or a function
returning a poiter to _something_. But, before check that
the asterisk, stuffs of steps 1 and 2 are enclosed within
a parantheses? Yes, they are. So,
( *foo ( char *ctx ) )
" ... foo is a function which takes pointer to an object of
type char ... "
4. Now, see on the right side of
( *foo ( char *ctx ) )
We have again an argument list of a function! Repeat the steps
2 and 3 to find that:
"foo is a function which takes a pointer to an object of type char
as an argument; and, it returns a pointer to function which takes
an int, and a pointer to an object of type long and returns an int."