Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!bloom-beacon!adam.pika.mit.edu!scs From: scs@adam.pika.mit.edu (Steve Summit) Newsgroups: comp.lang.c Subject: null if statements Message-ID: <12685@bloom-beacon.MIT.EDU> Date: 15 Jul 89 00:27:20 GMT References: <713@srhqla.SR.COM> Sender: daemon@bloom-beacon.MIT.EDU Reply-To: scs@adam.pika.mit.edu (Steve Summit) Lines: 31 in article <713@srhqla.SR.COM>, tcm@srhqla.SR.COM (Tim Meighan) writes: > 1. There is rarely, if ever, a case when it would be reasonable for a > program to contain an if() statement that, when evaluated as true, > does absolutely nothing. (In other words, simply fall through to > the code to be executed when the if() is false.) Just yesterday I discovered, to my considerable astonishment, a good use for an if statement which always evaluates as false, and does nothing: if(0) ; #ifdef onething else if(Streq(command, "agitate")) agitate(); #endif #ifdef anotherthing else if(Streq(command, "blend")) blend(); #endif #ifdef yetanotherthing else if(Streq(command, "churn")) churn(); #endif else fprintf(stderr, "unknown command \"%s\"\n", command); The first, empty if keeps the code syntactically correct regardless of which of the "real" branches are #ifdeffed out. Steve Summit scs@adam.pika.mit.edu