home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!spool.mu.edu!yale.edu!ira.uka.de!slsvaat!josef!kanze
- From: kanze@us-es.sel.de (James Kanze)
- Subject: Re: Is (p) instead of (p!=NULL) portable?
- In-Reply-To: nh@cbnewsg.cb.att.com's message of Tue, 26 Jan 1993 09:17:08 GMT
- Message-ID: <KANZE.93Jan28192623@slsvdnt.us-es.sel.de>
- Sender: news@us-es.sel.de
- Organization: SEL
- References: <1993Jan25.125627.29030@ugle.unit.no> <1993Jan26.091708.11214@cbfsb.cb.att.com>
- Date: 28 Jan 93 19:26:23
- Lines: 36
-
- 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?
- |> >
- |> >
- |> > Robert
-
- |> It is NOT portable for C.
-
- Yes it is. There is no difference between ANSI C and C++ in this
- regard.
-
- |> 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++.
-
- And equally wrong in C.
- --
- James Kanze email: kanze@us-es.sel.de
- GABI Software, Sarl., 8 rue du Faisan, F-67000 Strasbourg, France
- Conseils en informatique industrielle --
- -- Beratung in industrieller Datenverarbeitung
-