Here is how to make sense of complicated typedefs: First look at the line with typedef
taken out:
int16_t NEW_TYPE (* product_init_t)(product_descript_t *const description);
Then work out what this line would declare: it's a variable called product_init_t
with a certain type.
Finally, adding typedef
means that it declares product_init_t
to be an alias for that certain type, instead of a variable of that type.
To work out the above declaration, you can use cdecl
, or you can attack it from the outside-in using knowledge of the possible declarators (pointer, array, function).
In this case the outer-most feature is the parameter list at the right, so we suspect this might be a function declarator. Function declarators look like (roughly):
returntype function_name (parameters_opt)
although bear in mind that a common compiler extension is to specify additonal properties of the function via __declspec
or otherwise, in the same place as the return type; or there might be extern "C"
there, and so on.
So far we are at the stage that (*product_init_t)
is a function with int16_t NEW_TYPE
as return type (and possible declspecs), and parameter list (product_descript_t *const description)
.
Finally, * product_init_t
is just a pointer declarator, so we conclude that product_init_t
is a pointer to a function of the above type.
Your comments indicate being unsure about NEW_TYPE
. It will be something that is already defined earlier (or a compiler extension keyword); perhaps preprocessing the code with gcc -E
would help if your IDE can't find its definition.