Yet Another Argument for Nested Comments

Tony Sanders sanders at peyote.cactus.org
Thu Feb 7 12:51:30 AEST 1991


In article <1991Jan28.205309.2836 at unislc.uucp> scl at 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 at peyote.cactus.org
First rule of software:  Throw the first one away.
and so on...



More information about the Comp.lang.c mailing list