Casting NULL again

lmiller at venera.isi.edu.UUCP lmiller at venera.isi.edu.UUCP
Sat Jan 31 03:56:33 AEST 1987


In article <12211 at sun.uucp> guy at sun.UUCP (Guy Harris) writes:
>>Thanks for your comments on this matter. Unfortunately, most
>>of you misunderstood what I wanted. I realize that under some
>>machines ints are 16 bits and pointers are 32. I have a MAC and
>>thats the case there and I often have to pass parameters as
>>(long)NULL to get the right number of bytes passed.
>>That's nothing to do with pointers per se,=that's a "problem" of
>>dealing with long int parameters.
>
>The person who claimed that the reason you cast NULL to a particular
>pointer type is that pointers to different types might have different
>sizes is only partially correct.  The *real* reason is that pointers
>to different types have different types!  Too many C programmers feel
>that correct C is anything they can get away with, and too many
>programmers get burned by this.
>
> etc., etc.

For what it's worth, I'd like to add my two cents in support of this point
of view.  Though it's rediculous now, there may come a time when automatic
verification of programs is reasonable.  Verification is aided by languages
with well defined semantics.  It is impossible when we use tricks.  So as
programmers who also give at least lip service to "computer science", we
should try to make our programs as formally correct as possible.  And as
has been repeatedly noted, doing so aids portability, maintainability,
etc., etc.



More information about the Comp.lang.c mailing list