Newsgroups: comp.lang.c Path: utzoo!henry From: henry@zoo.toronto.edu (Henry Spencer) Subject: Re: Using a define that hasn't been #defined Message-ID: <1990Oct3.180300.28041@zoo.toronto.edu> Organization: U of Toronto Zoology References: <5101@hsv3.UUCP> Date: Wed, 3 Oct 90 18:03:00 GMT In article <5101@hsv3.UUCP> jls@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@zoo.toronto.edu utzoo!henry