[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

12. Statements

impossible conditions
Use the construct assert (0); when an impossible condition is detected, i.e., for an impossible default: case in a switch statement.

switch statements
Always include a default case in a switch, even if it is a failing assertion or an empty statement.

labels and statements
A label, both goto targets and cases, must be followed by a statement, even if that is an empty statement. This is required by the ANSI standard.

infinite loops
Write infinite loops with for (;;).

There are three acceptable uses for goto, two of them related:

Many error recovery actions of the first two types can be avoided by use of pools. The third type is rarely necessary.

common case following if
In an if/else construct, put the common case after the if, not the else.

multi-statement macros
If a macro's definition contains multiple statements, enclose them with do { ... } while (0) to allow them to work properly in all syntactic circumstances.

[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Ben Pfaff on September, 11 2001 using texi2html