I'm learning to build complex types. Here I defined a pointer to an array 5 of shorst using typedef:
typedef short (*mytype)[5];
I'm trying to find out how to to the same with the #define directive and if it is even feasible. I tried this, but it does not work:
#define MYTYPE (short*)[5]
It seems like this directive cannot be applied for defining something more complex than a pointer or a struct. So, what is the point here?
*behing a typedef. The*in source code is a good visual note about something being a pointer; in the same way, the absence of*is a good indicator something is not a pointer. Hiding the*in a typedef breaks this visual indication.short (*)[5], but that would only be good in certain contexts, such ascastsorsizeofoperands, not for declarations.#definedirectives are not particularly for creating aliases for types. Appropriate uses include very short “functions”, providing some substitutions that are useful for customizing software to various environments, or signaling features to turn on/off.MYTYPE var;it asks for an identifier or(#definedirectives are not for creating aliases for types.