use of NULL

Wayne A. Throop throopw at xyzzy.UUCP
Sat Feb 25 07:56:06 AEST 1989


> heather at SEAS.UCLA.EDU
> Why doesn't the C standard
> treat NULL or 0 (a static/constant NULL or 0, i.e. indicated at compile time)
> passed to a function that has a pointer value in the function prototype 
> as a special case and do the cast implicitly?

Good point.  The answer is that the discussion has been about what
happens when there is no prototype in scope.  It happens as you
suggest when there is, but when there isn't, there isn't enough
information to do the cast correctly.  If the type of the formal
argument is unknown to the compiler, even if the compiler was aware of
NULL as a keyword, it would not know which type of null pointer was
wanted.  This is crucial for some architectures, where pointers to (or
of) different types have different storage requiremnts or formats.

--
God made integers.  All else is the work of man.
                    --- Leopold Kronecker (1823-1891)
-- 
Wayne Throop      <the-known-world>!mcnc!rti!xyzzy!throopw



More information about the Comp.lang.c mailing list