Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!apple!sun-barr!cs.utexas.edu!ut-emx!ibmchs!auschs!awdprime!sanders.austin.ibm.com!sanders From: sanders@peyote.cactus.org (Tony Sanders) Newsgroups: comp.lang.c Subject: Re: Yet Another Argument for Nested Comments Summary: I hate it when that happens Message-ID: <5164@awdprime.UUCP> Date: 7 Feb 91 01:51:30 GMT References: <1991Jan28.205309.2836@unislc.uucp> Sender: news@awdprime.UUCP Reply-To: sanders@peyote.cactus.org (Tony Sanders) Organization: IBM AWD, Austin Lines: 46 Originator: sanders@sanders.austin.ibm.com In article <1991Jan28.205309.2836@unislc.uucp> scl@unislc.uucp (Sean Landis) writes: >These arguments always seem more compelling when they reveal our own errors! >I had a header file, hash.h, that looked like: With nested comments you have the same type of problem. What if you nested comments when you didn't mean to. Better to just look for the obvious before spending 4 hours looking for a compiler bug or somesuch. I've done the same thing over various problems. Once I spent several hours of my time trying to find out why something like this didn't work: system("stty raw"); /* only I didn't use system */ /* much simplified of course */ read(0,s,1); s[1] = '\0'; fprintf(stderr,"debug: why isn't %s working\n",s); switch(s[0]) { case 'a': dothis(); break; case 'b': dothat(); break; } First I was working from home... It worked just fine. When I got to work, the 'a' worked ok but the 'b' was broken. (actually it was like 'g' and 'o' and 'q' worked but 'z' and 'w' didn't or somesuch) but the printf worked just fine. After a couple of hours debug time I went into the other office to ask a friend of mine to look at it and it was the other way around!!! Different commands were broken. Now what had I done. My problem was I was looking for a bug in the compiler or the IOP or the tty driver or something. After debugging the .s file with another friend we finally fixed the problem: *s = *s & 0x7f; -- sanders@peyote.cactus.org First rule of software: Throw the first one away. and so on...