Function pointer prototype interpretation

A

Alfonso Morra

Hi all,

I came accross this FP signature and it has me baffled.

Can anyone explain this signature to me - i.e what are the input and
output types ?

void(*(*foo)(int))(int,void(*)(int))

Thanks
 
K

Krishanu Debnath

Alfonso said:
Hi all,

I came accross this FP signature and it has me baffled.

Can anyone explain this signature to me - i.e what are the input and
output types ?

void(*(*foo)(int))(int,void(*)(int))

Thanks

Did you try cdecl?

[x0030819 asic Linux ~]: cdecl
Type `help' or `?' for help
cdecl> explain void(*(*foo)(int))(int,void(*)(int))
declare foo as pointer to function (int) returning pointer to function
(int, pointer to function (int) returning void) returning void
cdecl> quit
[x0030819 asic Linux ~]:


Krishanu
 
M

Martin Ambuhl

Alfonso said:
Hi all,

I came accross this FP signature and it has me baffled.

Can anyone explain this signature to me - i.e what are the input and
output types ?

void(*(*foo)(int))(int,void(*)(int))

cdecl <<EOD
explain void(*(*foo)(int))(int,void(*)(int))
quit
EOD

declare foo as pointer to function (int) returning pointer to function
(int, pointer to function (int) returning void) returning void
 
B

Bryan Donlan

Alfonso said:
Hi all,

I came accross this FP signature and it has me baffled.

Can anyone explain this signature to me - i.e what are the input and
output types ?

void(*(*foo)(int))(int,void(*)(int))

Thanks

cdecl> explain void(*(*foo)(int))(int,void(*)(int))
declare foo as pointer to function (int) returning pointer to function (int,
pointer to function (int) returning void) returning void

Source code for cdecl is available from
http://ftp.debian.org/debian/pool/main/c/cdecl/cdecl_2.5.orig.tar.gz
 
J

John Bode

Alfonso said:
Hi all,

I came accross this FP signature and it has me baffled.

Can anyone explain this signature to me - i.e what are the input and
output types ?

void(*(*foo)(int))(int,void(*)(int))

Thanks

foo -- foo
*foo -- is a pointer
(*foo)() -- to a function
(*foo)(int) -- taking one int parameter
*(*foo)(int) -- returning a pointer
(*(*foo)(int))() -- to a function
(*(*foo)(int))(int, void(*)(int)) -- taking two parameters,
one int and the other
a pointer to a function
taking one int parameter
and returning void
void (*(*foo)(int))(int, void(*)(int)) -- returning void

To summarize, foo is a pointer to a function that returns a pointer to
a function that returns void.
 
A

Alfonso Morra

John said:
foo -- foo
*foo -- is a pointer
(*foo)() -- to a function
(*foo)(int) -- taking one int parameter
*(*foo)(int) -- returning a pointer
(*(*foo)(int))() -- to a function
(*(*foo)(int))(int, void(*)(int)) -- taking two parameters,
one int and the other
a pointer to a function
taking one int parameter
and returning void
void (*(*foo)(int))(int, void(*)(int)) -- returning void

To summarize, foo is a pointer to a function that returns a pointer to
a function that returns void.
Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,169
Messages
2,570,919
Members
47,458
Latest member
Chris#

Latest Threads

Top