Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rutgers!sunybcs!bingvaxu!leah!uwmcsd1!marque!ddsw1!gryphon!greg From: greg@gryphon.CTS.COM (Greg Laskin) Newsgroups: comp.sys.ibm.pc Subject: Re: ** Re: MSC 4.0 Large Model ** Original Posters problem solved!!! Message-ID: <1331@gryphon.CTS.COM> Date: Tue, 25-Aug-87 22:51:16 EDT Article-I.D.: gryphon.1331 Posted: Tue Aug 25 22:51:16 1987 Date-Received: Fri, 28-Aug-87 01:04:50 EDT References: <10400006@altger.UUCP> <72@cunixc.columbia.edu> <1014@bsu-cs.UUCP> <4291@teddy.UUCP> <283@axis.fr> Reply-To: greg@gryphon.CTS.COM (Greg Laskin) Organization: Trailing Edge Technology, Redondo Beach, CA Lines: 58 In article <283@axis.fr> mickey@axis.fr (Michael Dance) writes: >In article <4291@teddy.UUCP>, jpn@teddy.UUCP (John P. Nelson) writes: >> >> To summarize: when passing a null pointer to a function, you should >> always cast the 0 or NULL to the proper pointer type. In any other >> context, you may use 0 or NULL interchangably. CORRECT! > >So for functions NULL is the correct thing to pass, this should be cast >to the correct type if the type is not char * as other pointer types >may be treated differently on different machines (eg alignment) WRONG! > >As for assignment defined to work with 0 or NULL, this may be true K&R: " ... it is guaranteed that assignment of the constant 0 to a pointer will produce a null pointer distiguishable from a pointer to any object." >but > char *fred = NULL; >is clearer than using 0 and only needs 3 extra key-presses so MATTER OF TASTE but agrees in general with K&R. >it is surely preferable. Certain machines (eg Motorola sv6350) >NEED (char *)0 so NULL is shorter to type. BROKEN COMPILER! > >Moral: > in general, but not always, things such as NULL may be optional > but were defined to avoid the programmer needing to be aware > of differences in machine architecture, if you dont use them > thats OK but your programs may only work on the machine on which > you wrote them Good moral. Wrong reason. K&R: "C guarantees 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. In general, integers cannot meaningfully be assigned to pointers; zero is a special case." -- Greg Laskin "When everybody's talking and nobody's listening, how can we decide?" INTERNET: greg@gryphon.CTS.COM UUCP: {hplabs!hp-sdd, sdcsvax, ihnp4}!crash!gryphon!greg UUCP: {philabs, scgvaxd}!cadovax!gryphon!gregf