home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / cplus / 20049 < prev    next >
Encoding:
Text File  |  1993-01-28  |  1.5 KB  |  49 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!spool.mu.edu!yale.edu!ira.uka.de!slsvaat!josef!kanze
  3. From: kanze@us-es.sel.de (James Kanze)
  4. Subject: Re: Is (p) instead of (p!=NULL) portable? 
  5. In-Reply-To: nh@cbnewsg.cb.att.com's message of Tue, 26 Jan 1993 09:17:08 GMT
  6. Message-ID: <KANZE.93Jan28192623@slsvdnt.us-es.sel.de>
  7. Sender: news@us-es.sel.de
  8. Organization: SEL
  9. References: <1993Jan25.125627.29030@ugle.unit.no> <1993Jan26.091708.11214@cbfsb.cb.att.com>
  10. Date: 28 Jan 93 19:26:23
  11. Lines: 36
  12.  
  13. In article <1993Jan26.091708.11214@cbfsb.cb.att.com>
  14. nh@cbnewsg.cb.att.com (nicholas.hounsome) writes:
  15.  
  16. |> From article <1993Jan25.125627.29030@ugle.unit.no>, by robert@alkymi.unit.no (Robert Schmidt):
  17. |> > 
  18. |> > In PC C's, the NULL pointer is defined with a bit pattern of all zero's,
  19. |> > and the constructs 
  20. |> >       if (p)
  21. |> > and
  22. |> >       if (!p)
  23. |> > checks for NULL and non-NULL respectively.  Is this portable to *all*
  24. |> > platforms?
  25. |> > 
  26. |> > 
  27. |> > Robert
  28.  
  29. |> It is NOT portable for C.
  30.  
  31. Yes it is.  There is no difference between ANSI C and C++ in this
  32. regard.
  33.  
  34. |> It is portable for C++ which is the group that you have posted to -
  35. |> did you mean to?
  36.  
  37. |> #define NULL (void*)0
  38. |> if(p==NULL)
  39.  
  40. |> This is WRONG in C++ and right in C.
  41. |> (char*)0 is even worse in C++.
  42.  
  43. And equally wrong in C.
  44. --
  45. James Kanze                             email: kanze@us-es.sel.de
  46. GABI Software, Sarl., 8 rue du Faisan, F-67000 Strasbourg, France
  47. Conseils en informatique industrielle --
  48.                    -- Beratung in industrieller Datenverarbeitung
  49.