how has C bitten you?

Tom Stockfisch tps at sdchema.UUCP
Thu Aug 15 06:00:12 AEST 1985


<>
roy at phri.UUCP (Roy Smith) writes:

>	Here's one that just got me:
>
>		if (sv > score);   <----- note extraneous semi-colon
>			score = sv;

This type of error is easy to find with cb(1), which indents your code
according to its logic.  The above fragment is turned by cb into

		if (sv > score);
		score = sv;

cb is particularly useful if you have macro functions, as these can easily
cause unexpected control-of-flow problems and are expanded on one long
line.  I often do
		
		cc -E prog.c | cb | cat -s

The -E flag just runs the preprocessor, and
the cat -s is to get rid of the masses of white space which lines like
"#include <stdio.h>" cause.

				-- Tom Stockfisch



More information about the Comp.lang.c mailing list