Everytime I look at a C function pointer, my eyes glaze over. I can’t read them.
From here, here are 2 examples of function pointer TYPEDEFS:
typedef int (*AddFunc)(int,int);
typedef void (*FunctionFunc)();
Now I’m used to something like:
typedef vector<int> VectorOfInts ;
Which I read as
typedef vector<int> /* as */ VectorOfInts ;
But I can’t read the above 2 typedefs. The bracketing and the asterisk placement, it’s just not logical.
Why is the * beside the word AddFunc..?
The actual type of the first one is
(that is, a pointer to a function that takes two parameters of type
intand returns anint)The
*identifies it as a function pointer.AddFuncis the name of the typedef.cdecl can help with identifying particularly complex type or variable declarations.