Path: utzoo!utgpu!watmath!watdragon!lion!jyegiguere From: jyegiguere@lion.waterloo.edu (Eric Giguere) Newsgroups: comp.lang.c Subject: Re: use of if (!cptr) and if (cptr), where cptr is a * Message-ID: <15267@watdragon.waterloo.edu> Date: 20 Jul 89 01:37:26 GMT References: <10099@mpx2.mpx.com> <93@microsoft.UUCP> <10100@mpx2.mpx.com> Sender: daemon@watdragon.waterloo.edu Reply-To: jyegiguere@lion.waterloo.edu (Eric Giguere) Organization: U. of Waterloo, Ontario Lines: 23 The following quote from the draft ANSI Standard should be of interest: "An integral constant expression with the value 0, or such an expression cast to type void *, is called a null pointer constant." (3.2.2.3) and then later "NULL ... expands to an implementation-defined null pointer constant" (4.1.5) So even if your compiler uses its own non-zero internal representation for the null pointer, it must be able to catch expressions of the form if( ptr != 0 ) if( ptr != ( 10 * 10 - 101 + 1 ) ) if( ptr != (void *) (5-5) ) and your macro for NULL better expand to a zero-valued integer expression. Eric Giguere 268 Phillip St #CL-46 For the curious: it's French ("jee-gair") Waterloo, Ontario N2L 6G9 Bitnet : GIGUERE at WATCSG (519) 746-6565 Internet: giguere@aries5.UWaterloo.ca "Nothing but urges from HELL!!"