Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!uwvax!uwmacc!hobbes!root From: root@hobbes.UUCP (John Plocher) Newsgroups: comp.sys.ibm.pc Subject: Re: ** Re: MSC 4.0 Large Model ** Original Posters problem solved!!! Message-ID: <187@hobbes.UUCP> Date: Fri, 21-Aug-87 19:55:14 EDT Article-I.D.: hobbes.187 Posted: Fri Aug 21 19:55:14 1987 Date-Received: Sun, 23-Aug-87 10:18:20 EDT References: <10400006@altger.UUCP> <72@cunixc.columbia.edu> <1014@bsu-cs.UUCP> <3352@zen.berkeley.edu> Reply-To: root@hobbes.UUCP (John Plocher) Followup-To: comp.sys.ibm.pc Organization: U of Wisconsin - Madison Spanish Department Lines: 65 +---- Tim Iverson writes the following in article <3352@zen.berkeley.edu> ---- | Nick Christopher writes: | > 1) Use NULL not 0 as often as applicable. why? | Rahul Dhesi writes: | >Actually, I suggest simply casting 0 or NULL, whichever you use, to | >the correct type when passing it as a parameter. When simply using | >it for a comparison, a cast is not necessary and either may be used. | | A cast is necesary for a comparison with large model pointers in ---------- | both lattice C and MSC4.0. +---- nooooooooo! Rahul is completely correct. The correct definition for NULL is: #define NULL 0 /* NOT 0L !!! */ K&R page 97: "C guarentees that no pointer that validly points at data will contain zero, so a return value of zero can be used to signal an abnormal event ... . We write NULL instead of zero, however, to indicate more clearly that this is a special value for a pointer." Note: zero, not (long) 0 or 0L. The only time one MUST cast NULL is when it is used as a parameter to a function, as in: foo( (char *) NULL ); In this case it is best to cast all pointers AND other non-int values. K&R Page 41: "Implicit arethmetic conversions work much as expected. ... ... for each arethmetic operator, the following sequence of conversion rules is applied:" If one is Convert it to ------ ------------- char int short int float double Then if one is Convert other to Result ------ ---------------- ------ double double double long long long unsigned unsigned unsigned Otherwise the operands must be INT, and the result is INT K&R Page 49 expressly includes == and != as operators. (I'd say more, but a large lightning storm just came up and the systems are shutting down...) -- John Plocher uwvax!geowhiz!uwspan!plocher plocher%uwspan.UUCP@uwvax.CS.WISC.EDU