Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!julius.cs.uiuc.edu!apple!vsi1!hsv3!jls From: jls@hsv3.UUCP (James Seidman) Newsgroups: comp.lang.c Subject: Using a define that hasn't been #defined Message-ID: <5101@hsv3.UUCP> Date: 2 Oct 90 23:26:43 GMT Reply-To: jls@headland.UUCP (James Seidman) Organization: Video Seven / Headland Technology Lines: 34 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. For example, take the trivial case of this "program" ------- #define XYZZY 1 main() { #if XYZZU printf("xyzzy\n"); #else printf("plugh\n"); #endif } ------ Now, obviously that XYZZU was supposed to be an XYZZY, and I wanted to conditionally compile the first piece of code, not the second. But when I compile this, it doesn't even give me a friendly warning, and just assumes XYZZU is 0. (Which, I understand, is in accordance with ANSI- defined behavior.) 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... -- Jim Seidman (Drax), the accidental engineer. "There's a certain freedom to being completely screwed." - The Freshman UUCP: ames!vsi1!headland!jls ARPA: jls%headland.UUCP@ames.nasa.arc.gov