home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!mole-end!mat
- From: mat@mole-end.matawan.nj.us
- Subject: Re: Is (p) instead of (p!=NULL) portable?
- Message-ID: <1993Jan26.182746.22842@mole-end.matawan.nj.us>
- Organization: :
- References: <1993Jan25.125627.29030@ugle.unit.no> <1993Jan26.091708.11214@cbfsb.cb.att.com>
- Date: Tue, 26 Jan 1993 18:27:46 GMT
- Lines: 31
-
- In article <1993Jan26.091708.11214@cbfsb.cb.att.com>, nh@cbnewsg.cb.att.com (nicholas.hounsome) writes:
- > From article <1993Jan25.125627.29030@ugle.unit.no>, by robert@alkymi.unit.no (Robert Schmidt):
-
- > > In PC C's, the NULL pointer is defined with a bit pattern of all zero's,
- > > and the constructs
- > > if (p)
- > > and
- > > if (!p)
- > > checks for NULL and non-NULL respectively. Is this portable to *all*
- > > platforms?
-
- > It is NOT portable for C.
-
- It _is_ portable for any C which conforms either to the standard or to
- the old K&R `de facto standard.'
-
- > It is portable for C++ which is the group that you have posted to -
- > did you mean to?
-
- > #define NULL (void*)0
- > if(p==NULL)
-
- > This is WRONG in C++ and right in C.
- > (char*)0 is even worse in C++.
-
- It is also wrong in C. See the comp.lang.c FAQ, a Truly Excellent document.
- --
- (This man's opinions are his own.)
- From mole-end Mark Terribile
-
- mat@mole-end.matawan.nj.us, Somewhere in Matawan, NJ
-