Path: utzoo!attcan!uunet!mcvax!hp4nl!ruuinf!piet From: piet@ruuinf (Piet van Oostrum) Newsgroups: comp.lang.c Subject: Re: use of NULL Keywords: NULL zero 0 C Microsoft Message-ID: <1153@ruuinf.UUCP> Date: 23 Feb 89 09:44:31 GMT References: <1167@unisec.usi.com. <5312@turnkey.TCC.COM. <9582@smoke.BRL.MIL. <399@twwells.uucp: <973@optilink.UUCP> Sender: piet@ruuinf.UUCP Reply-To: piet@ruuinf (Piet van Oostrum) Organization: Dept of Computer Science, University of Utrecht, Holland Lines: 36 In-reply-to: cramer@optilink.UUCP (Clayton Cramer) In article <973@optilink.UUCP>, cramer@optilink (Clayton Cramer) writes: `In article <399@twwells.uucp:, bill@twwells.uucp (T. William Wells) writes: `: In article <965@optilink.UUCP: cramer@optilink.UUCP (Clayton Cramer) writes: `: : . Using 0 instead of NULL is perfectly acceptable. `: : `: : No it isn't. Segmented architecture machines will have problems with `: : that in large model. Microsoft defines NULL as 0L, not 0, in large `: : model. Pushing an int 0 instead of a long 0 will screw you royally `: : on the PC. `: And on and on and on and on ..... You are all wrong. ANSI C says that the CONSTANT 0 used in a pointer context should always give the ``null'' pointer for that pointer type. BUT It must be clear from the context that a pointer type is required. The only good way to give a null pointer to a function is to write funct ( (foo *) 0 ); ^^^^^^^ i.e cast it. If you have function prototypes, the cast will be done by the compiler. Even if you want to use NULL you have to write: funct ( (foo *) NULL ); If you don't cast, it may work on your particular compiler, but some day it will hit you, unless you throw away your program before anybody else gets a chance to use it. -- Piet van Oostrum, Dept of Computer Science, University of Utrecht Padualaan 14, P.O. Box 80.089, 3508 TB Utrecht, The Netherlands Telephone: +31-30-531806. piet@cs.ruu.nl (mcvax!hp4nl!ruuinf!piet)