Seven Original Sins of K&R (Long)

Stan Brown, Oak Road Systems browns at iccgcc.decnet.ab.com
Fri Oct 5 04:25:43 AEST 1990


M>
Followup-To: >

Lines: 29

WARNING:  Nit about to be picked.

In <1990Sep28.144753.23727 at zoo.toronto.edu> 
henry at zoo.toronto.edu (Henry Spencer) writes:
>>In article <1990Sep27.131329.26616 at phri.nyu.edu> 
  roy at phri.nyu.edu (Roy Smith) writes:
>>>... I meant to
>>>write:
>>>
>>>#define NULL (""[0])
> 
>Roy, apart from not being a compile-time value, which limits its use,
>this is exactly and precisely equivalent to
> 
>#define	NULL	0

Not exactly or precisely.  Every time the first version is invoked, it
creates a separate instance of a one-byte string.  So you chew up static
data storage.  Depending on how your compiler does alignmnet, it may be
two or four bytes each time--or more.  And in large model with Microsoft
C, some combinations of options could put each "" in its own data
segment!

Is that horse dead yet?  Lord knows I've been beating it enough! :-)


The above is my own opinion and not attributable to any other person or
organization.                        email: browns at iccgcc.decnet.ab.com
Stan Brown, Oak Road Systems, Cleveland, Ohio, U.S.A.    (216) 371-0043



More information about the Comp.lang.c mailing list