Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Aug 2000 20:52:35 +0300
From:      Anatoly Vorobey <mellon@pobox.com>
To:        David Scheidt <dscheidt@enteract.com>
Cc:        "Thomas M. Sommers" <tms2@mail.ptd.net>, chat@freebsd.org
Subject:   Re: C time functions - problem
Message-ID:  <20000810205235.A13316@happy.checkpoint.com>
In-Reply-To: <Pine.NEB.3.96.1000810124500.82980A-100000@shell-1.enteract.com>; from dscheidt@enteract.com on Thu, Aug 10, 2000 at 12:46:17PM -0500
References:  <20000810191221.A12280@happy.checkpoint.com> <Pine.NEB.3.96.1000810124500.82980A-100000@shell-1.enteract.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Aug 10, 2000 at 12:46:17PM -0500, David Scheidt wrote:
> On Thu, 10 Aug 2000, Anatoly Vorobey wrote:
> 
> :On Thu, Aug 10, 2000 at 01:30:44AM -0400, Thomas M. Sommers wrote:
> :> 
> :> "An integer constant expression with the value 0, or such an expression
> :> cast to type void *, is called a null pointer constant. If a null
> :> pointer constant is converted to a pointer type, the resulting pointer,
> :> called a null pointer, is guaranteed to compare unequal to a pointer to
> :> any object or function."
> :> 
> :> There are very few circumstances in which you need to cast 0 to make it
> :> a null pointer constant.
> :
> :I am not aware of any such circumstances at all. 0 can always be used 
> :instead of NULL, and, since I find it completely unambiguous, I always
> :use 0 for null pointers.
> 
> This is only true on systems where 0 is not a valid address.  On such
> systems, NULL pointers aren't equal to 0.

This is incorrect. The underlying representation of the NULL pointer is
totally irrelevant. The compiler treats the integer constant 0 as the
null pointer, and the programmer should never worry about how the null
pointer is actually represented. Thus comparing a pointer with 0 will
always test it for being a null pointer, regardless of how null pointer is
represented on the particular architecture. See the standard or a FAQ for
more details.

-- 
Anatoly Vorobey,
mellon@pobox.com http://pobox.com/~mellon/
"Angels can fly because they take themselves lightly" - G.K.Chesterton


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-chat" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000810205235.A13316>