Rules:
5.1.a. The names of all new data types, including structures, unions, and enumerations, shall consist only of lowercase characters and internal underscores and end with ‘_t’.
5.1.b. All new structures, unions, and enumerations shall be named via a typedef.
5.1.c. The name of all public data types shall be prefixed with their module name and an underscore.
Example:
typedef struct
{
uint16_t count;
uint16_t max_count;
uint16_t _unused;
uint16_t control;
} timer_reg_t;
Reasoning: Data type names and variable names are often appropriately similar. For example, a set of timer control registers in a peripheral calls out to be named ‘timer_reg’. To distinguish the structure definition that defines the register layout, it is valuable to create a new type with a distinct name, such as ‘timer_reg_t’. If necessary this same type could then be used to create a shadow copy of the timer registers, say called ‘timer_reg_shadow’.
Enforcement: An automated tool shall scan new or modified source code prior to each build to ensure that the keywords struct, union, and enum are used only within typedef statements or in anonymous declarations. Code reviews shall be used to enforce the naming rules for new types.