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

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!mole-end!mat
  3. From: mat@mole-end.matawan.nj.us
  4. Subject: Re: Is (p) instead of (p!=NULL) portable?
  5. Message-ID: <1993Jan26.182746.22842@mole-end.matawan.nj.us>
  6. Organization: :
  7. References: <1993Jan25.125627.29030@ugle.unit.no> <1993Jan26.091708.11214@cbfsb.cb.att.com>
  8. Date: Tue, 26 Jan 1993 18:27:46 GMT
  9. Lines: 31
  10.  
  11. In article <1993Jan26.091708.11214@cbfsb.cb.att.com>, nh@cbnewsg.cb.att.com (nicholas.hounsome) writes:
  12. > From article <1993Jan25.125627.29030@ugle.unit.no>, by robert@alkymi.unit.no (Robert Schmidt):
  13.  
  14. > > In PC C's, the NULL pointer is defined with a bit pattern of all zero's,
  15. > > and the constructs 
  16. > >       if (p)
  17. > > and
  18. > >       if (!p)
  19. > > checks for NULL and non-NULL respectively.  Is this portable to *all*
  20. > > platforms?
  21.  
  22. > It is NOT portable for C.
  23.  
  24. It _is_ portable for any C which conforms either to the standard or to
  25. the old K&R `de facto standard.'
  26.  
  27. > It is portable for C++ which is the group that you have posted to -
  28. > did you mean to?
  29.  
  30. > #define NULL (void*)0
  31. > if(p==NULL)
  32.  
  33. > This is WRONG in C++ and right in C.
  34. > (char*)0 is even worse in C++.
  35.  
  36. It is also wrong in C.  See the comp.lang.c FAQ, a Truly Excellent document.
  37. -- 
  38.  (This man's opinions are his own.)
  39.  From mole-end                Mark Terribile
  40.  
  41.  mat@mole-end.matawan.nj.us, Somewhere in Matawan, NJ
  42.