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

Guideline:  9.4#2Checked automatically with code checker

Synopsis: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.
Language:C
Severity Level:4
Category:STATEMENTS


Description:

This means avoiding implicit comparison of char data against \\\\\\\\0, integral data against 0 and pointer data against the null pointer.

Example:

int a;
...
if ( a ) /* WRONG - compare should be explicit */

should be

Example:

int a;
...
if ( a > 0 ) /* RIGHT */

Since C has no built-in boolean type, a boolean type should be defined in a library.

Example:

typedef int boolean;