Objective
A C coding style which:
- is concise
- minimizes diffs for common maintenance and refactoring tasks
- is stable under automated indent tools (indent, uncrustify)
- is generally independent of brace-style
- easily greppable
Common Maintenance Tasks
- Modify a function declaration
- Modify a struct or enum
General
- No horizontal alignment (this includes comment boxes)
List elements
Function parameter lists
- Separate lines for:
- Return and storage type
- Function name
- Parameters
- Comma-decl style for parameters
extern return_type_t
Function(
int param1
, int param2
, int param3
);
Enumerations
- Mandatory last element
enum Enumeration {
ZEROTH = , /**! Short description */
FIRST = 1,
SECOND = 2,
/** Mandatory last element */
LAST
};
Expressions
- Separate lines for each argument
- New indent for each sub-expression
if (booleanA
&& booleanB
|| (booleanC
&& booleanD
)
)
{
}