Typedef'ing a function

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

    #1

    Typedef'ing a function

    Is the following a legal typedef? (gcc -Wall -ansi -pedantic says it's ok)

    typedef void Callback(void *obj);

    I mean "a Callback is a function taking void * and returning void" (not
    "a pointer to function"). Then of course I would use pointers to
    Callback, like

    void apply(Callback *f, void *a[], size_t size)
    {
    size_t i;

    for (i = 0; i < size; i++)
    f(a[i]);
    }

    I prefer it to

    typedef void (*Callback)(voi d *obj);

    because I don't like hiding pointers behind typedefs.
Working...