Blip said:
typedef struct Ctrl_t
{
Int8U *pData;
Int32U Counter;
UsbEpStatus_t EpStatus;
}Ctrl_t, *pCtrl_t;
It appears that two synonyms are defined for the structure but one is
a pointer? What is happening here?
Poor style, IMHO.
There aren't two synonyms for the structure. There's one synonym for
the structure and another synonym for a pointer to the structure.
The stuff starting with "struct Ctrl_t" and ending with "}" declares a
structure type whose name is "struct Ctrl_t".
The "typedef ... Ctrl_t" declares the name "Ctrl_t" as an alias for
the type "struct Ctrl_t". This is a common style; I don't bother with
such typedefs myself, but I won't get into the reasons here, so don't
worry about that.
The "typedef ... *pCtrl_t" declares pCtrl_t as an alias for the type
"struct Ctrl_t*" (i.e., a pointer to your struct). That's considered
by most C programmers to be a bad idea. C uses pointers for many
things (array indexing, emulating pass-by-reference, etc.). Hiding
the pointer-ness of a type behind a typedef name can make the code
that uses it difficult to read and understand.
If you're using an object or value of a pointer type, you *need to
know* that it's a pointer. I suppose the "p" prefix does that, but
the "*" character does it much more clearly.