I understand that typedef can be used to define a new custom type, for example:
// simple typedef
typedef unsigned long ulong;
// the following two objects have the same type
unsigned long l1;
ulong l2;
I recently came across this typedef, and got lost in deciphering what is going on in the declaration:
typedef int16_t CALL_CONVENTION(* product_init_t)(product_descript_t *const description)
Can someone guide me and explain what this is doing?
EDIT: changed NEW_TYPE to CALL_CONVENTION. It's a define. Thanks for spotting that out.
It declares type product_init_t
as a pointer to a function which
product_descript_t *const description
;int16_t
;CALL_CONVENTION
(as @M.M suggested even when it was misnamed).P.S. Since "a complete answer in 2016 should show the modern way to write this type-alias
" (@Howard Hinnant), here it is:
using product_init_t = int16_t (CALL_CONVENTION *)(product_descript_t *const description);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With