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 ** NULL isn't always 0 Message-ID: <1332@gryphon.CTS.COM> Date: Tue, 25-Aug-87 23:11:16 EDT Article-I.D.: gryphon.1332 Posted: Tue Aug 25 23:11:16 1987 Date-Received: Fri, 28-Aug-87 01:37:40 EDT References: <10400006@altger.UUCP> <72@cunixc.columbia.edu> Reply-To: greg@gryphon.CTS.COM (Greg Laskin) Organization: Trailing Edge Technology, Redondo Beach, CA Lines: 57 In article <158@dolphy.UUCP> jmg@dolphy.UUCP (Jeffrey Greenberg) writes: >/**/ > >You SHOULD use NULL instead of 0 or 0L etc. because things like > char *x; > x = (char *) NULL; >does not mean that the address that x is pointing to is address 0. >It is not true on all machines... Any code you write like this >won't run on a Sun machines to name one. This is a machine/OS dependency. This code will work fine on a Sun machine. It will produce the same result as: char *x x=0; If it did not, NULL would have been incorrectly defined. >If you do things like, > > char *x, dog; > if( !x ) /* This is wrong... not portable */ > x = &dog; > >because it is not true between machines/os and your code will fail. If this is not true, you are not using a C compiler. K&R: "The result of the logical negation operator ! is 1 if the value of its operand is 0, 0 if the value of its operand is non-zero. ... It is applicable to any arithmetic type or to pointer". A null pointer is a pointer to which the constant 0 has been assigned. NULL is user to clearly indicate a special pointer value of 0. > >The unspeakable 'far' & 'near' stuff that microsoft uses is a kludge for dealing >with 16bit machines and 32bit addressing. There is no compilation model that requires the use of the keywords "far" and "near" to produce a correctly working program. Those keywords are available, if enabled at compilation time, to permit finer tuning of programs, if desired. It would not be a bad practice to define these extended keywords: #define FAR far #define NEAR near #define HUGH hugh in a header file so that they would be convenienly removable in environments where they have no effect. -- 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!greg