unable to understand this typedef

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sanchit

    unable to understand this typedef

    What does this typedef represent?
    typedef void Sigfunc(int);



    -Sanchit
  • Eric Sosman

    #2
    Re: unable to understand this typedef

    Sanchit wrote:
    What does this typedef represent?
    typedef void Sigfunc(int);
    It declares Sigfunc as an alias for "function of one
    int argument returning no value."

    You can't actually use Sigfunc to define a function:

    Sigfunc func ... er, where's my parameter list?
    {
    ... er, how do I refer to the parameters?

    ... er, what do I return? it looks like I
    should return a function, but ...?
    }

    However, you *can* use it to declare a function:

    Sigfunc sig1; /* sig1 is a function ... */
    Sigfunc sig2; /* sig2 is a function ... */

    And you can use it to describe a function pointer:

    Sigfunc *fptr = sig1;

    Comment

    Working...