Article View: comp.lang.c.moderated
Article #2334Re: references wanted
From: news
Date: Tue, 19 Mar 1996 12:48
Date: Tue, 19 Mar 1996 12:48
31 lines
1883 bytes
1883 bytes
In article <4ian7m$h54@solutions.solon.com> runner!amileto@uunet.uu.net (Angelo John Mileto) writes: >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? > Consider a machine where a (char *) and an (int *) are not the same (Honeywell DPS/6 for example), and a function written with the old K&R style. Then you always needed to cast your NULL pointers to get them into the right size/format for the called function. I used to keep arround a macro for just this #define Nullp(type) ((type *)NULL) All this changed with ANSI C and prototypes. By using protypes instead I can just code NULL, and the explicit cast is no longer needed. I find it a better technique. I no longer routinely liter code with casts. This reduces clutter in the code and make the remaining casts stand out as something special. Summary. Prior to ANSI C and prototypes, coding (type *)0 was a useful practice. It has been superceded by changes in the language and is no longer particularly good style. [Except, of course, in variadic function argument lists. -mod]
Technical Details
Message-ID:
<4imaec$dvd@solutions.solon.com>Path:
arc1-ca.pugleaf.net!solon.com!not-for-mailReferences:
<4i6fn8$p0g@solutions.solon.com> <4i97jv$8hn@solutions.solon.com> <4ian7m$h54@solutions.solon.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail From: news@Thinkage.On.CA Newsgroups: comp.lang.c.moderated Subject: Re: references wanted Date: 19 Mar 1996 06:48:12 -0600 Organization: Thinkage Ltd. Sender: clc@solutions.solon.com Approved: clc@solutions.solon.com Message-ID: <4imaec$dvd@solutions.solon.com> References: <4i6fn8$p0g@solutions.solon.com> <4i97jv$8hn@solutions.solon.com> <4ian7m$h54@solutions.solon.com> NNTP-Posting-Host: solutions.solon.com