Barr Group FacebookBarr Group TwitterBarr Group LinkedInBarr Group Vimeo


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.


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.




These rules shall be enforced during code reviews.


One smart reader of the coding standard has noticed an apparent contradiction between this rule and Rule 3.1.b. The latter specifies that an assignment operator (=) should have precisely 1 space on each side. But in this Rule 3.2.c the left side of that operator may have more than 1 space, to facilitate the assignment alignment.

Though we agree that's a contradiction, for now we'll leave the rules worded the way they are and you can simply prioritize following Rule 3.2.c above Rule 3.1.b.

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

Sign up for our newsletter today!

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.