Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!uwm.edu!ux1.cso.uiuc.edu!phil From: phil@ux1.cso.uiuc.edu (Phil Howard KA9WGN) Newsgroups: comp.lang.c Subject: NULL question not in FAQ Message-ID: <1991Mar26.235643.4498@ux1.cso.uiuc.edu> Date: 26 Mar 91 23:56:43 GMT Organization: University of Illinois at Urbana Lines: 45 Given that the compiler is supposed to translate the constant "0" to the appropriate value for a NULL pointer on the machine type, how does one get a pointer value whose representation happens to be all zeroes, but is a non-NULL pointer? Are all of these equivalent or are any differnt? p = ( (char *) 0 ); p = ( (char *) 00 ); p = ( (char *) 0x0 ); p = ( (char *) 0x00 ); p = ( (char *) 1-1 ); If not, what are they supposed to compile to? Suppose I do this: char *p; int i; p = NULL; i = (int) p; Will I get a value of zero in "i" always, regardless of the way the machine type represents a NULL? I am wanting to discern whether or not the special case of a pointer value being translated to the NULL representation is done with the particular constant of a single digit "0" or if it is done with ANY constant whose integer value is numerically 0. For low level code, e.g. drivers and such, where portability and machine independence are not issues, it would still be nice to be able to cast address values into pointers as desired. Some machine types might very well have special functionality at address 0x00000000 and uses some other form of address for a NULL. Some machine types actually have no NULL at all and one is simply chosen by convention. Can someone summarize this, depending one what the real answers are, and include it in the FAQ in the section on NULL? This might clear up (or confuse further) the distinction of NULL. -- /***************************************************************************\ / Phil Howard -- KA9WGN -- phil@ux1.cso.uiuc.edu \ \ Lietuva laisva -- Brivu Latviju -- Eesti vabaks / \***************************************************************************/