cepek@vixvax.mgi.com (04/06/91)
Does ANSI really state that #if ABC == DEF evaluates to FALSE if symbol DEF is not defined!? If so, I'm disappointed, since #ifdef and #if defined already provide that functionality. If not, I'd appreciate the reference in the spec. (Neither of my references [K&R II, Kochan] address this issue directly.) Thanks in advance. ,---------------------------------,___________________________ / Mike Cepek, Programmer/Analyst / Internet: CEPEK@MGI.COM / \ Management Graphics, Inc. \ Voice: +1 612/851-6112 \ "Engage." / 1401 East 79th Street / Operator: +1 612/854-1220 / \ Minneapolis, MN 55425 USA \ Fax: +1 612/854-6913 \ `--------------------------------/___________________________/
torek@elf.ee.lbl.gov (Chris Torek) (04/06/91)
In article <1991Apr5.161945.889@vixvax.mgi.com> cepek@vixvax.mgi.com writes: >Does ANSI really state that > > #if ABC == DEF > >evaluates to FALSE if symbol DEF is not defined!? No. However, in this case, #if DEF is the same as #if 0 Furthermore, if ABC is either #define'd as the preprocessor value 0 (i.e., a preprocessor expression which evaluates to 0) or is undefined, #if ABC == DEF is the same as #if 0 == 0 or #if 1 X3.159-1989 merely states that at that particular point in preprocessor arithmetic, all `variable names' are treated as zero. (Macro expansion has already taken place, replacing any #define'd tokens with their definitions.) -- In-Real-Life: Chris Torek, Lawrence Berkeley Lab CSE/EE (+1 415 486 5427) Berkeley, CA Domain: torek@ee.lbl.gov
gwyn@smoke.brl.mil (Doug Gwyn) (04/06/91)
In article <1991Apr5.161945.889@vixvax.mgi.com> cepek@vixvax.mgi.com writes: >Does ANSI really state that > #if ABC == DEF >evaluates to FALSE if symbol DEF is not defined!? No -- undefined identifiers are replaced by 0 in #if expressions. That was existing behavior in e.g. the Reiser CPP.