Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!micomvax!musocs!mcgill-vision!mouse From: mouse@mcgill-vision.UUCP Newsgroups: comp.lang.c Subject: Re: Use of NULL as a pointer in C Message-ID: <559@mcgill-vision.UUCP> Date: Sat, 22-Nov-86 17:47:27 EST Article-I.D.: mcgill-v.559 Posted: Sat Nov 22 17:47:27 1986 Date-Received: Mon, 24-Nov-86 19:29:08 EST References: <1376@batcomputer.TN.CORNELL.EDU> <8957@sun.uucp> <250@rabbit1.UUCP> Organization: McGill University, Montreal Lines: 30 In article <250@rabbit1.UUCP>, barber@rabbit1.UUCP (Steve Barber) writes: > The use of the identifier NULL, as defined by stdio.h in all UNIXes > I've ever seen [...], by itself as any kind of pointer, is a > non-portable usage and as such is incorrect [...] Nearly. It *is* portable to write (assuming NULL is 0, as it is on our system) ptr_var = NULL; or if (ptr_expr == NULL) (or !=). It is *not* portable to write setbuf(stdout,NULL); /* should be (char *)NULL */ (even aside from the issue of setbuf()'s portability). > When writing code, bite the bullet and type those extra 8 or so > characters [...]: (char *) NULL, (int *) NULL, or [whatever]. I prefer to simply never use NULL. I write my code with zeros. This way I don't get bitten when porting to a system where some well-meaning clod with the famous "little learning" decided to "avoid" the "problem" and make NULL ((char *)0). der Mouse USA: {ihnp4,decvax,akgua,utzoo,etc}!utcsri!mcgill-vision!mouse think!mosart!mcgill-vision!mouse Europe: mcvax!decvax!utcsri!mcgill-vision!mouse ARPAnet: think!mosart!mcgill-vision!mouse@harvard.harvard.edu [USA NSA food: terrorist, cryptography, DES, drugs, CIA, secret, decode]