🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c.moderated
Article #2335

Re: references wanted

#2335
From: ANH
Date: Tue, 19 Mar 1996 12:51
49 lines
2034 bytes
In article <4ietaq$b0n@solutions.solon.com>, stanr@tiac.net (Stan Ryckman) writes:
 > In article <4ian7m$h54@solutions.solon.com>,
 > Angelo John Mileto <runner!amileto@uunet.uu.net> wrote:
 > :In article <4i97jv$8hn@solutions.solon.com> ANH@KUHUB.CC.UKANS.EDU writes:
 > :>But here is one simple rule,  always use (Type*)0 and not null for null 
 > :>pointer check.  Show my a thousand standards that say I don't need 
 > :>to do that, I would still use the construct.
 > :>
 > :>Anh
 > :
 > :I'll byte, what exactly does (Type*)0 do that NULL doesn't do and why will
 > :it always work whereas NULL may or may not?
 > 
 > Actually....
 > 
 > 	printf( "%p\n", (void*) NULL); /* OK */
 > 	printf( "%p\n", (Type*) NULL); /* not OK */
 > 	printf( "%p\n",  NULL);        /* not OK */
 > 
 > (Same if 0 is used rather than NULL in any of these.)
 > 
 > (See 4.9.6.1.)
 > 
 > Cheers,
 > Stan.
 > --
 > Stan Ryckman  (stanr@tiac.net)
 >   (Apologies for non-responses or late responses to some posts;
 >   .newsrc was trashed and I'm trying to get it back to where it was.)

Really?  Seems like I need to update my 'beliefs' :-)  Actually, (TYPE*)0
has been recommended to me by several professors of mine who worked as
software engineer as places such as Bell Labs.

Just to re-iterate,

tMyType *ptr;
if (ptr==NULL) {
	... 
}

is a perfectly safe construct?

[Yes, and in fact, so is
	if (ptr == 0)
 and it is guaranteed equivalent. -mod]

Anh
Technical Details
Message-ID: <4imak1$e0j@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
References: <4i6fn8$p0g@solutions.solon.com> <4i97jv$8hn@solutions.solon.com> <4ietaq$b0n@solutions.solon.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: ANH@KUHUB.CC.UKANS.EDU
Newsgroups: comp.lang.c.moderated
Subject: Re: references wanted
Date: 19 Mar 1996 06:51:13 -0600
Organization: University of Kansas Academic Computing Services
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4imak1$e0j@solutions.solon.com>
References: <4i6fn8$p0g@solutions.solon.com> <4i97jv$8hn@solutions.solon.com> <4ietaq$b0n@solutions.solon.com>
NNTP-Posting-Host: solutions.solon.com
X-VMS-To: in%"comp-lang-c-moderated@uunet.uu.net"