I want to declare a type of pointer that points to a function, so I'm trying:
typedef void (*print)(void);
works great
void (*print)(void);
p is a ponter variable, not a type.
typedef (void) (*print)(void);
expected error identifier or '(before' void
typedef void (*)(void) Print;
error: expected '=,', ';,' asm or '_ attribute _ before' Print.
My question is:
Should I use typedef
to declare a type of function pointer?
Why typedef (void) (*print)(void);
not this way? what does ()
mean?
Why can't I write like this: typedef void (*)(void) Print
?
source share