In a header file a definition is given by
static void (*foo[CONST]) (void);
What is its meaning ?
In a header file a definition is given by
static void (*foo[CONST]) (void);
What is its meaning ?
It's meaning is an array with CONST
amount of elements of function pointers with signature void f(void);
These things get used most often for callbacks, for example the function atexit
.
Find the leftmost identifier and work your way out, remembering that ()
and []
bind before *
(*ap[]
is an array of pointers, (*pa)[]
is a pointer to an array, *fp()
is a function returning a pointer, (*pf)()
is a pointer to a function):
foo -- foo
foo[CONST] -- is a CONST-element array
*foo[CONST] -- of pointers
(*foo[CONST])( ) -- to functions
(*foo[CONST])(void) -- taking no parameters
void (*foo[CONST])(void) -- and returning void
static void (*foo[CONST])(void) -- and foo has static extent
-- meaning it is not accessible by name
-- outside of the current translation unit (file)