Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!lll-lcc!unisoft!hoptoad!academ!killer!jfh From: jfh@killer.UUCP Newsgroups: comp.lang.c Subject: Re: Query: Implementation with non-zero NULL Message-ID: <957@killer.UUCP> Date: Thu, 4-Jun-87 11:38:22 EDT Article-I.D.: killer.957 Posted: Thu Jun 4 11:38:22 1987 Date-Received: Sun, 7-Jun-87 18:38:28 EDT References: <158@delftcc.UUCP> <3673@gitpyr.gatech.EDU> <20130@sun.uucp> Organization: The Unix(tm) Connection, Dallas, Texas Lines: 57 Keywords: C, NULL, portability Summary: References please ... (I don't remember reading Kernighan, Ritchie and Harris, do you? :-) In article <20130@sun.uucp>, guy%gorodish@Sun.COM (Guy Harris) writes: [ along with someone else whose name got trashed at some point in the games ] > > On the PRIME system under PRIMIX, there is a special "undefined pointer" > > value. This value is used by the procedure call mechanism when fewer > > arguments are passed to a subroutine by reference (ie FORTRAN) than > > are expected. Because of this, constructs such as the > > > > if(p) > > > > Do not yield correct results. > > Translation: PRIME has no implementation of C on their machines. If > the construct > > if (p) > > where "p" is a pointer does not compare "p" with the undefined > pointer value, then the language being implemented isn't C. Now for my two cents worth. Seven years later, my K&R is still at the bookstore waiting to be bought, so I can't quote from the Holy Bible according to K&R. From the current edition of the C Language (out of the Plexus Programmer's Guide) I quote: 2.6.7 - Equality Operators "A pointer may be compared to an integer only if the integer is the constant 0. A pointer to which 0 has been assigned is guaranteed not to point to any object and will appear to be equal to 0. In conventional usage, such a pointer is considered to be null." 2.7.7, pp 3 - Initialization "Static and external variables that are not initialized are guaranteed to start off at zero. ..." -- Plexus Sys5 Programmer's Guide From 2.6.7 it appears Guy is correct (references, documentation - I keep asking but no one listens ... :-(, 0 and (char *) 0 are identical when used in the comparision in the posting. From 2.7.7 we see that even static and external variables are nulled. (The ANSI standard says it much better.) If your standard I/O declares NULL == 0x(something other than zero) and then expects it to work, you are doomed to eternal buggyness. - John. Senior Systems Analyst Disclaimer: I didn't do it. Honest. HECI Exploration Co, Inc. UUCP: { backbone } ! killer!jfh Dallas, Republic of Texas "If you don't own an oil well, buy one".