Barr Group TwitterBarr Group Vimeo

Rules

The following C coding rules relate to the use of white space to align certain elements of source code:

Rule 3.2.a.) The names of variables within a series of declarations shall have their first characters aligned.

Rule 3.2.b.) The names of struct and union members shall have their first characters aligned.

Rule 3.2.c.) The assignment operators within a block of adjacent assignment statements shall be aligned.

Rule 3.2.d.) The # in a preprocessor directive shall always be located in column 1, except when the directive is nested within an outer #if or #ifdef.

Reasoning

Visual alignment emphasizes similarity. A series of consecutive lines containing variable declarations is easily spotted and understood as a block. Blank lines and unrelated alignments should be used to visually distinguish unrelated blocks of code appearing nearby.

Exceptions

None.

Enforcement

These rules shall be enforced during code reviews.

What’s happening and how it’s done. Get in the know.

Sign Up for Our Newsletter

Receive free how-to articles, industry news, and the latest info on Barr Group webinars and training courses via email. 

To prevent automated spam submissions leave this field empty.