Path: utzoo!attcan!utgpu!watmath!att!dptg!rutgers!tut.cis.ohio-state.edu!unmvax!bbx!bbxsda!scott From: scott@bbxsda.UUCP (Scott Amspoker) Newsgroups: comp.lang.c Subject: Re: Abandon NULL for (0) Message-ID: <146@bbxsda.UUCP> Date: 21 Sep 89 22:42:17 GMT References: <6502@ux.cs.man.ac.uk> <14718@bfmny0.UU.NET> Reply-To: scott@bbxsda.UUCP (Scott Amspoker) Organization: Basis International, Albuquerque, NM Lines: 32 In article <14718@bfmny0.UU.NET> tneff@bfmny0.UU.NET (Tom Neff) writes: >In article <6502@ux.cs.man.ac.uk> ian@ux.cs.man.ac.uk (Ian Cottam) writes: >> I propose that the integral constant expression (0) be used instead of >> NULL. > >However (0) is not explicitly cast to a pointer type, as NULL may be >presumed to be when appropriate. For instance if I refer to, but do not >declare or define, an external routine that accepts a single pointer as >its argument, by saying myproc((0)), the compiler will Miranda it into a >regular int, rather that ((void *) 0), which might have a different size >and representation. Good point. Professionally, I cast everything - makes lint real happy. At home I use 0 for a null pointer. I test pointers with expressions like: if (pointer)... /* at home */ if (!pointer)... as opposed to if (pointer!=(char *)0) /* at work */ Modern C compilers are quite reliable about this - but you have to watch out with those function calls. However, function prototyping solves that problem. In fact, function prototyping has saved my butt on many occasions. Too bad it is not yet common enough to use professionally. -- Scott Amspoker Basis International, Albuquerque, NM (505) 345-5232