C declaration

B

Bibi

What does the following C declaration means?

void *(disp)(int))

I can't even begin to understand it!

Thank you in advance!

--B
 
A

Allan Bruce

Bibi said:
What does the following C declaration means?

void *(disp)(int))

I can't even begin to understand it!

Thank you in advance!

It is a pointer to a function that returns a void and takes an int as an
arguement.
Allan
 
V

Victor Nazarov

Bibi said:
What does the following C declaration means?

void *(disp)(int))

I can't even begin to understand it!

Thank you in advance!

--B

It is incorrect. What about the brace at the end of the line? If you
have meant
void *(disp)(int);
then this is an equevalent for
void *disp (int);
which is the declaration of function with single argument of type int
which returns pointer to void (nothing).

vir
 
T

Thomas stegen

Allan said:
It is a pointer to a function that returns a void and takes an int as an
arguement.

Err, nope... Assuming
void *(disp)(int);

Then it is a function prototype for a function called disp
which returns a pointer to void and takes an int as the argument.
 
O

osmium

Bibi said:
What does the following C declaration means?

void *(disp)(int))

I can't even begin to understand it!

It is a fragment of something. There is no semi colon and there are
mismatched parens. Try to type more carefully.
 
A

Allan Bruce

Thomas stegen said:
Err, nope... Assuming
void *(disp)(int);

Then it is a function prototype for a function called disp
which returns a pointer to void and takes an int as the argument.

so it is, I should have read more carefully, if the OP had asked about

void (*disp)(int);

then that is a pointer to a function. The OPs function can be rewritten as:

void * disp(int);

which is a 'normal' function called disp returning a void pointer.

Allan
 
B

Bibi

Allan Bruce said:
so it is, I should have read more carefully, if the OP had asked about

void (*disp)(int);

then that is a pointer to a function. The OPs function can be rewritten as:

void * disp(int);

which is a 'normal' function called disp returning a void pointer.

Allan

Well sorry for the mistake. it was in fact
void *(disp)(int)
It was in the argument of the function sigset(2).
void(*sigset(int sig, void (*disp)(int)))(int);
Now it makes sense to me.
Thank you all!

--B
 
J

James McIninch

<posted & mailed>
What does the following C declaration means?

void *(disp)(int))

I can't even begin to understand it!

Thank you in advance!

--B

You are missing a parenthesis, but it says 'disp is a pointer to a function
that takes and integer argument'.
 

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,141
Messages
2,570,817
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top