Casting NULL?
Guy Harris
guy%gorodish at Sun.COM
Sat Jan 24 19:26:53 AEST 1987
>I have a question about pointers: I just recently read
>a C text where whenever NULL was passed as a parameter
>it was casted to the proper type.
All praise to the author of the text for that!
>He claimed that this is required because pointers to different types of
>objects may not be the same size.
That isn't the half of it. NULL is *!*!NOT*!*!* a pointer, in most
implementations of C, it's just 0. (There are good reasons for
this.) There are plenty of implementations where 0 and "(char *)0"
are not the same size.
Furthermore, there is no guarantee whatsoever that an integral
constant 0 and and a null pointer of some type have the same bit
pattern.
More information about the Comp.lang.c
mailing list