TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
TIOBE - C Coding Standard
Search

Category: STATEMENTS

Synopsis:


Description:

Coding Rules

NameCheckedSynopsis
9.1#1 Checked automatically with code checker Statements must not be labelled.
9.1#2 Checked automatically with code checker Only a conventional case .. default construct may follow a switch statement.
9.1#3 Checked automatically with code checker A label should be on a separate line
9.2#1 Checked automatically with code checker A statement must have a side-effect, i.e., it must do something.
9.2#2 Checked automatically with code checker A null statement, if used, shall appear on a line by itself.
9.4#1 Checked automatically with code checker Controlling expressions shall not contain assignments.
9.4#2 Checked automatically with code checker To clarify the actual test performed in a selection statement, there should be an explicit comparison operator unless the compared object is of effectively 'Boolean' type.
9.4.1#1 Checked automatically with code checker Multiple choice constructs programmed using if ... else if ... shall have a "catch-all" clause.
9.4.1#2 Checked automatically with code checker The else and if should appear with the else indented to match the if above.
9.4.1#5 Checked automatically with code checker An if statement must be followed by a {..} construct even when only one statement, (null (;) or otherwise) is used.
9.4.1#6 Checked automatically with code checker An if statement must not lead to a degenerate comparison, for example the comparison of an unsigned quantity against a negative-valued constant.
9.4.2#1 Checked automatically with code checker All switch statements shall have a default clause, even if that clause is empty.
9.4.2#2 Checked automatically with code checker Each case clause and default clause shall be terminated by a break statement unless empty.
9.4.2#3 Checked automatically with code checker The default clause should be the last entry in the switch statement.
9.4.2#5 Checked automatically with code checker The switch expression shall not contain the ">", ">=", "<", "<=", "==", "!=", "&&", "||" or "!" operators.
9.4.2#6 Checked automatically with code checker The switch expression shall contain at least one case label.
9.5#1 Checked automatically with code checker To clarify the actual test performed in an iteration statement, there should be an explicit comparison operator.
9.5.1#1 Checked automatically with code checker A while statement must be followed by a {..} construct.
9.5.2#1 Checked automatically with code checker A for statement must be followed by a {..} construct even if only one statement is used.
9.5.2#2 Checked automatically with code checker The use of floating point variables as loop variables is forbidden.
9.5.2#3 Checked automatically with code checker A control variable shall not be altered by the body of a for statement.
9.5.2#4 Checked automatically with code checker Only loop control variable expressions should appear in the for statement.
9.5.2#5 Checked automatically with code checker Use a "for" loop construction for an infinite loop.
9.6.1#1 Checked automatically with code checker The break statement should not be used to exit from an iteration statement, (for or while).
9.6.2#1 Checked automatically with code checker The continue statement shall not be used.
9.6.3#1 Checked automatically with code checker The address of an object of automatic storage shall not be returned.
9.6.3#2 Checked automatically with code checker There should only be one return statement in a function returning non-void and this should appear at the bottom of the function. There should be no return statement in a function returning void.
9.7#1 Checked automatically with code checker The goto statement is unstructured and shall not be used.