1

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

Community
  • 1
  • 1
Daeden
  • 481
  • 1
  • 6
  • 20

2 Answers2

3

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
Keith Nicholas
  • 43,549
  • 15
  • 93
  • 156
2

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.

ouah
  • 142,963
  • 15
  • 272
  • 331