I'm confused (Re: What C compilers have non-zero null pointers?)
Karl Heuer
karl at haddock.ima.isc.com
Tue Jul 17 08:50:37 AEST 1990
In article <30820 at eerie.acsu.Buffalo.EDU> chu at acsu.buffalo.edu (john c chu) writes:
>In article <9007161750.AA00664 at edison.CHO.GE.COM> rja <rja at edison.cho.ge.com> writes:
>>[On a machine where the internal representation of a null pointer wasn't 0]
>>It of course did compile fine as long as one used sense and compared
>>pointers to NULL rather than a constant of zero...
If it was compiling C, then it should have worked without that clause.
>I thought comparing a pointer to NULL was the same as comparing a pointer to
>(a properly cast) zero.
In a pointer context, NULL and properly-cast 0 and naked 0 are all equivalent:
each refers to the null pointer of the type implied by the context.
As an argument to a function not covered by a prototype (this being the only
place you can put a null pointer constant and not have a pointer context), a
properly-cast NULL and a properly-cast 0 are equivalent. Naked 0 and naked
NULL are both incorrect if a null pointer was desired.
>I have a feeling most of my questions are probably answered [in the FAQ]
Yes, they are.
Karl W. Z. Heuer (karl at kelp.ima.isc.com or ima!kelp!karl), The Walking Lint
More information about the Comp.lang.c
mailing list