if (p) ...

Roger Klorese roger at celtics.UUCP
Thu Oct 17 08:08:40 AEST 1985


In article <2098 at brl-tgr.ARPA> harged%ti-eg.csnet at CSNET-RELAY.ARPA (Richard_Hargrove) writes:
>
>means, whether it is good style, &c... is overlooking something.
>Nowhere in K & R is the meaning of the distinguished constant
>NULL defined. I thought its definition was implementation
>dependent. It just so happens that all implementations I know of
>use 0 (or 0L). But nothing *requires* this.

In fact, I've worked in an environment (PRIMOS and other Multics-style systems)
with segmented addressing schemes (and demand-paged virtual memory) wherein 
the definition of a NULL pointer was any address in the designated-highest-
possible segment (defined as octal 7777).  Thus, for C to see a pointer as 
null required conversion from 7777/0 to 0 (or seg 0 loc 0, which is a valid
address) and back again!  

In summary:

YEAH, a portable test is necessary that does not depend on NULL being ZERO.

-- 
--------------------------------------------------------------------------------
| ... "What were you expecting, rock'n'roll?"                                  |
|Roger B.A. Klorese                                                            |
|Celerity Computing, 40 Speen St., Framingham, MA 01701, (617) 872-1772        |
|UUCP:                                 ARPA:                                   |
|decvax-\    bang-\                        celerity!celtics!roger at sdcsvax.ARPA |
|ucbvax--\   akgua-\                                                           |
|ihnp4----\-sdcsvax-\-celerity!celtics!roger                - or -             |
|- or -                                      celtics!roger at bu-cs.ARPA          |
|seismo----\harvard---\bu-cs!celtics!roger                                     |
--------------------------------------------------------------------------------



More information about the Comp.lang.c mailing list