When should use use _t
? Never? It's reserved by a major standard (POSIX) and even if it's not now, your code might someday be used in a POSIX environment, so using _t
is a bad idea.
I would go further to say that over-use of typedef
is bad in general. If your type is a struct
, union
, or enum
, use these keywords when you declare variables and it makes your code more clear. Use of typedef
is best reserved for when you want to make the underlying type invisible for abstraction/encapsulation purposes. A few great examples from standard C are size_t
, int32_t
, mbstate_t
, and the stdio FILE
.
Some of the worst abuses of typedef
are by the Windows API (WORD
, DWORD
, INT
, LPSTR
etc.) and glib (gint
, gchar
, etc.). Making duplicates of the standard C types with the same intended usage is only confusing and serves to lock developers into your library/platform by polluting all the code with these nonstandard type names.