Path: utzoo!attcan!uunet!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!agate!helios.ee.lbl.gov!pasteur!postgres!jas From: jas@postgres.uucp (James Shankland) Newsgroups: comp.lang.c Subject: Re: Abandon NULL for (0) Message-ID: <17505@pasteur.Berkeley.EDU> Date: 22 Sep 89 04:35:03 GMT References: <6502@ux.cs.man.ac.uk> <14718@bfmny0.UU.NET> <146@bbxsda.UUCP> Sender: news@pasteur.Berkeley.EDU Reply-To: jas@postgres.berkeley.edu (Jim Shankland) Organization: The Eddie Group Lines: 28 In article <146@bbxsda.UUCP> scott@bbxsda.UUCP (Scott Amspoker) writes: >Professionally, I cast everything - makes lint real happy. Actually, in most cases, lint couldn't care less. It is a fallacy that the degree of portability of your code varies directly with the number of casts in it. Casts are conversions whose semantics are, in many cases, implementation-dependent. >At home I use 0 for a null pointer. I test pointers with expressions >like: > if (pointer)... /* at home */ > if (!pointer)... Stylistically a little dubious, in my opinion, but certainly widely practiced. Also entirely safe. >as opposed to > > if (pointer!=(char *)0) /* at work */ > >Modern C compilers are quite reliable about this ... Modern C compilers will reliably generate warnings on this if `pointer' has any type other than `char *'. Modern C compilers will be entirely happy if you leave out the cast, provided `pointer' is any scalar or pointer type. jas