typedef struct name
{
}name_t;
name
here is a struct tag and superfluous for the normal use-case, since you end up with a typedef
anyhow and should only use name_t
in your code from there on.
The only reason you'd add a tag there is the special case where you need a self-referencing struct such as a struct name* next;
member in a linked list or such. In such cases we have to use the struct tag since the typedef name cannot be used before the typedef statement itself is done. Another alternative to that is to forward declare the struct.
The _t
naming is industry standard way of naming types since the dawn of time. Unfortunately, the POSIX standard had the misguided idea to disallow such naming, so if you care about POSIX compliance, you should not name your types with _t
in the end. If you don't care about POSIX, you should use _t
because it gives proper, self-documenting code.