Path: utzoo!censor!isgtec!robert From: robert@isgtec.uucp (Robert Osborne) Newsgroups: comp.lang.c Subject: Re: Constants in conditionals Message-ID: <858@isgtec.UUCP> Date: 19 Feb 91 17:54:27 GMT References: <9890@dog.ee.lbl.gov> <1991Feb18.113919.28217@watmath.waterloo.edu> Sender: news@isgtec.UUCP Reply-To: robert@isgtec.UUCP (Robert Osborne) Organization: ISG Technologies Inc. Mississauga Ont. Canada Lines: 29 datangua@watmath.waterloo.edu (David Tanguay) writes: > In article <9890@dog.ee.lbl.gov> torek@elf.ee.lbl.gov (Chris Torek) writes: > >Both of these are effectively the same as `if (0)', hence a good compiler > >should warn about a constant in conditional context [...] > > Oooo I hope not! I occasionally use constants in ifs. Oooo I hope SO! I occasionally use constants in ifs... usually by mistake! Since it is sort of a stupid thing to do (why use an "if" when you already know which way you are going to branch?) I would hope that it would produce a warning. > "if( PATCH_MODE ) { ... }", where PATCH_MODE is a cpp macro (0 or 1). > I know I coud use #if (or #ifdef), but I find them too ugly. Nice attitude towards programming; "I don't use any language constructs *I* don't find aesthetically pleasing" I know that any compile dependency, whether for architecture, Unix type, or to exclude some feature (ie. debugging), will have an #if something #endif associated with it. (Well, I at least at ISG I know this; now it seems this doesn't extend to the whole world :-( > I could also use an external, but then I don't get > the dead code elimination. Oh now I see, you left the smilee off your article. Rob. -- Robert A. Osborne ...uunet!utai!lsuc!isgtec!robert or robert@isgtec.uucp