C Coding Style

Table of Content

C Features

Use ANSI C or C99 without extension.

Indentation

Indents using tabs and tabs are 4 characters.

Line length

Line length MUST be BELOW 80 colummns.

Comments

Comments use /* ... */ not //

:warning: Be aware that comments should be used only when it’s necessary, code must always be self documented.

Braces and Spaces

Braces

{ and } are always, ALWAYS, on their own line.

if (my_func() < 0)
{
    (...)
}

Space

Use space after: if, switch, case, for, do, while.

But not with: sizeof, typeof, alignof, __attribute__.