Daeden
Daeden

Reputation: 511

Can someone explain the meaning of this 'typedef'?

Can someone explain this typedef please?

typedef void (*_sig_func_ptr)(int);

Understanding its meaning seems critical to answering my question: MPICH2 compilation issue using Cygwin

Upvotes: 1

Views: 126

Answers (2)

ouah
ouah

Reputation: 145919

This is the syntax of the typedef of a function pointer type.

Here _sig_func_ptr is an alias for the type void (*)(int).

An object of type _sig_func_ptr is a pointer to a function with one int parameter and that returns nothing.

Upvotes: 2

Keith Nicholas
Keith Nicholas

Reputation: 44316

it declares a type which is a function pointer which takes an int and returns void

can be used like :-

void blah(int x)
{
}


_sig_func_ptr ptr;

ptr = blah;  // make ptr point to blah

ptr(12);     // now we can call blah by using the function pointer

Upvotes: 3

Related Questions