Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!ames!ucbcad!ucbvax!decvax!decwrl!sun!gorodish!guy From: guy@gorodish.UUCP Newsgroups: news.software.b,comp.lang.c Subject: Re: News for Xenix on PC AT ? Message-ID: <17436@sun.uucp> Date: Mon, 27-Apr-87 14:34:22 EDT Article-I.D.: sun.17436 Posted: Mon Apr 27 14:34:22 1987 Date-Received: Wed, 29-Apr-87 00:47:24 EDT References: <18346@ucbvax.BERKELEY.EDU> <145@sds.UUCP> <17005@sun.uucp> <146@sds.UUCP> <5787@brl-smoke.ARPA> <888@viper.UUCP> Sender: news@sun.uucp Reply-To: guy@sun.UUCP (Guy Harris) Organization: Sun Microsystems, Mountain View Lines: 45 Xref: utgpu news.software.b:533 comp.lang.c:1859 > >He, I, and others have explained more than once before in the C newsgroup > >that the only fully correct definition of the macro NULL, as C now stands, > >is as 0. (Under the proposed ANSI standard you could probably get away > >with defining it as (void *)0.) > > > >Actualy, you -must- use (void *)0 -OR- 0 and be consistant one way or >the other. It's not an option... Why? > char *myfunc(ind, str, ind2) > int ind, ind2; > char *str; ... >>now, later in my program if I have NULL defined as 0, then the following >line will cause the wrong number of bytes to be pushed on the stack: > > myfunc( i1, NULL, i2 ); 1) Your program will *also* have problems if you define NULL as "(void *)0", if "(char *)0" and "(void *)0" don't have the same representation. 2) Your program *won't* have problems if you defined "myfunc" as char * myfunc(int ind, char *str, int ind2) ... because the compiler would perform the coercion of 0 into (char *)0. >You may claim, if you wish, that passing NULL as a constant is illegal, >but I've seen too many examples of code where it's been done to accept >that as a valid argument. If there already exists a large body of code >using a particular construct, then that construct may be "illegal" in >your opinion, but anyone discussing "the only fully correct definition" >must take it into account... No, they don't. Calling "myfunc(i1, NULL, i2)" is illegal if NULL is defined as 0, and "lint" will tell you that. No implementor is obliged to make this illegal construct work.