Could someone explain what is going on when we use the typedef “type
cast” syntax?
typedef int (*funcptr)(double); (Wiki)
funcptr x = (funcptr) NULL;
OR
pg470, K.N.King – Modern Approach
typedef int *Fcn(void);
typedef Fcn *Fcn_ptr;
typedef Fcn_ptr Fcn_ptr_array[10];
Fcn_ptr_array x;
Isn’t it:
typedef oldtype newtype;
typedef int Bool;
So how does: typedef int * Fcn(void) make sense??
Usually: int *Fcn(void), would be a function “Fcn” that has no
parameters and returns a pointer to an int.. if i stick a typedef what
happens??
funcptr is a pointer variable.. it’s not a type..? so how can he cast
NULL to (funcptr)???? Is this syntax explained clearly somewhere –
K.N.King just slams it into you without mentioning this peculiar syntax
anywhere..
from 《C language reference manual》, chapter 7:
so typedef int (*funcptr)(double) means funcptr is a function pointer,the function has one parameter double and return type is int.