Using a define that hasn't been #defined
Henry Spencer
henry at zoo.toronto.edu
Thu Oct 4 04:03:00 AEST 1990
In article <5101 at hsv3.UUCP> jls at headland.UUCP (James Seidman) writes:
>Recently I've run into a couple of hard-to-track bugs because I have
>a section of conditionally compiled code using a symbol which hasn't
>been defined...
>Now, my question is how other people avoid these same kinds of idiotic
>mistakes? Even if I put in "#if !defined(XYZZY)..." type things for
>every define, it still wouldn't catch all typos. There should be some
>way to avoid this idiotic kind of error...
Two rules that can help with this and related problems are:
1. When enumerating values for a code, start at 1, not 0.
2. Make sure that if the user hasn't specified a choice (e.g. hasn't
defined one of several symbols tested with #ifdef, or hasn't
given a non-zero value to something tested with #if) that
the result is a complaint, not a default choice.
--
Imagine life with OS/360 the standard | Henry Spencer at U of Toronto Zoology
operating system. Now think about X. | henry at zoo.toronto.edu utzoo!henry
More information about the Comp.lang.c
mailing list