🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #11473

Re: Ultimate Wait-GetMsg strategy (?)

#11473
From: Jan Hendrikx
Date: Mon, 13 Feb 1989 22:17
23 lines
1662 bytes
In article <6402@dayton.UUCP>, joe@dayton.UUCP (Joseph P. Larson) writes:
> >>:  while (!(imsg= GetMsg(win->UserPort)))
> 
> 2. GetMsg() returns a pointer.  "!" is a logic operator.  Just because NULL
> 	happens to be zero doesn't mean that "!" is the correct way of checking
> 	for it.  Good coding practice (as outlined by people with more letters
> 	after their name than I have) suggest you check pointers against NULL.
> 	If nothing else, it help assures better portability.  (There are machines
> 	where "!" won't work.  As of 2 years ago, Sperry's 1100 version of C
> 	required 1 36-bit word for the address and another byte for an offset
> 	in the 36-bit word that a pointer points to.  "!" on pointers wouldn't
> 	work....)

Sorry, but you are fortunately not right. 

(!expr) means the same as (expr != 0), which is THE test to test for a 
NULL pointer. Even if NULL pointers are internally not represented by
all-bits-zero, the compiler must recognize a comparison between a
pointer and the constant 0, and emit approprate code in case that that
compiler's internal representation of a NULL pointer is not the same
as 0. See relatively recent articles on comp.lang.c.

-Olaf Seibert.
Technical Details
Message-ID: <331@wn2.sci.kun.nl>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcvax!hp4nl!kunivv1!wn2!janhen
References: <8902100658.AA16049@postgres.Berkeley.EDU> <6777@polya.Stanford.EDU> <6402@dayton.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!mcvax!hp4nl!kunivv1!wn2!janhen
From: janhen@wn2.sci.kun.nl (Jan Hendrikx)
Newsgroups: comp.sys.amiga.tech
Subject: Re: Ultimate Wait-GetMsg strategy (?)
Summary: Yes it DOES work!
Message-ID: <331@wn2.sci.kun.nl>
Date: 13 Feb 89 22:17:46 GMT
References: <8902100658.AA16049@postgres.Berkeley.EDU> <6777@polya.Stanford.EDU> <6402@dayton.UUCP>
Organization: University of Nijmegen, The Netherlands.
Lines: 23