In C, the type specifier keywords of structures, unions and enumerations are mandatory, ie you always have to prefix the type's name (its tag) with struct
, union
or enum
when referring to the type.
You can get rid of the keywords by using a typedef
, which is a form of information hiding as the actual type of an object will no longer be visible when declaring it.
It is therefore recommended (see eg the Linux kernel coding style guide, Chapter 5) to only do this when
you actually want to hide this information and not just to save a few keystrokes.
An example of when you should use a typedef
would be an opaque type which is only ever used with corresponding accessor functions/macros.