unable to understand this typedef

Discussion in 'C Programming' started by Sanchit, Mar 20, 2008.

  1. Sanchit

    Sanchit Guest

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



    -Sanchit
    Sanchit, Mar 20, 2008
    #1
    1. Advertising

  2. Sanchit

    Eric Sosman Guest

    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;
    Eric Sosman, Mar 20, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nitin Goyal
    Replies:
    3
    Views:
    716
  2. Replies:
    3
    Views:
    261
  3. Angus
    Replies:
    6
    Views:
    323
    Andrey Tarasevich
    Mar 31, 2008
  4. oor
    Replies:
    0
    Views:
    1,343
  5. André Hänsel

    I don't understand typedef example

    André Hänsel, Mar 18, 2009, in forum: C Programming
    Replies:
    27
    Views:
    850
    Keith Thompson
    Mar 30, 2009
Loading...

Share This Page