Xref: utzoo comp.lang.c:35328 comp.std.c:4140 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker.mit.edu!bloom-beacon!deccrl!news.crl.dec.com!shlump.nac.dec.com!tkou02.enet.dec.com!jit345!diamond From: diamond@jit345.swstokyo.dec.com (Norman Diamond) Newsgroups: comp.lang.c,comp.std.c Subject: Re: Is it only ANSI C that allow #if to compare symbols? Keywords: sun C #if Message-ID: <1991Jan19.040820.1940@tkou02.enet.dec.com> Date: 19 Jan 91 04:08:20 GMT References: <1991Jan18.170921.4866@resam.dk> Sender: news@tkou02.enet.dec.com (USENET News System) Reply-To: diamond@jit345.enet@tkou02.enet.dec.com (Norman Diamond) Distribution: comp Organization: Digital Equipment Corporation Japan , Tokyo Lines: 39 In article <1991Jan18.170921.4866@resam.dk> andrew@resam.dk (Leif Andrew Rump) writes: >#define FOLDER fk >#ifdef FOLDER > part 1 >#endif >#if FOLDER == fk > part 2 >#endif > >It worked OK for part 1 ... but part 2 get compiled under any circumstances > >#ifdef FOLDER == CASE > part 2 >#endif > >So this rules out that the presence is equal 1 and absence equal 0! Absence equals zero, yes. Presence equals whatever the defined value is. Now let's see what happens when you test #if FOLDER == fk #if fk == fk #if 0 == fk #if 0 == 0 which is true. #ifdef FOLDER == CASE is syntactically invalid. Assume you meant #if and let's see: #if FOLDER == CASE #if 0 == CASE #if 0 == 0 If you want a macro to evaluate to something other than 0, you must give it a value (a replacement-list) that evaluates as a constant-expression. Doug Gwyn already posted correct examples. -- Norman Diamond diamond@tkov50.enet.dec.com If this were the company's opinion, I wouldn't be allowed to post it.