Barr Group FacebookBarr Group TwitterBarr Group LinkedInBarr Group Vimeo

Rules

The following C coding rules relate to use and placement of parentheses:

Rule 1.4.a.) Do not rely on C’s operator precedence rules, as they may not be obvious to those who maintain the code. To aid clarity, use parentheses (and/or break long statements into multiple lines of code) to ensure proper execution order within a sequence of operations.

Rule 1.4.b.) Unless it is a single identifier or constant, each operand of the logical && and || operators shall be surrounded by parentheses.

Example

if ((depth_in_cm > 0) && (depth_in_cm < MAX_DEPTH_IN_CM))
{
    depth_in_ft = convert_depth_to_ft(depth_in_cm);
}
return result;

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 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.