Standardization questions (cpp mostl - (nf)

jim at ism780b.UUCP jim at ism780b.UUCP
Wed Oct 17 14:40:04 AEST 1984


#R:decvax:-8300:ism780b:25500030:000:1134
ism780b!jim    Oct 15 14:18:00 1984

>> I disagree.  I've seen plenty of code which does
>>
>>       #if foo
>> or
>>       #if !foo
>>
>> and I don't think a "-Dfoo 0" should be required.
>
>Looks like you've seen plenty of code which is confused about the
>difference between testing whether a symbol is defined and testing its
>value.  That's a fairly fundamental confusion, and it's easily remedied by
>using ifdef/ifndef.  I don't see why poor usage becomes an argument in the
>standardization process.  (Well, in reality I do; I wish I didn't:-)

Look, poor usage is a matter of opinion.  Please show me in print any usage
recommendation that prefers #ifdef foo over #if foo.  Personally, I consider
#ifdef to be an obsolete precursor to #if.  And I think the default
value of "1" rather than "" when -Dfoo is given lends support to that
interpretation.  Given a choice between

#if machine1 || machine2 || machine3

and

#if defined(machine1) || defined(machine2) || defined(machine3)

I prefer the former (and note that the latter was neither documented nor
worked properly (try defined(STANDALONE)) until System V).

-- Jim Balter, INTERACTIVE Systems (ima!jim)



More information about the Comp.lang.c mailing list