home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / cplus / 19910 < prev    next >
Encoding:
Text File  |  1993-01-26  |  977 b   |  35 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!spool.mu.edu!uwm.edu!linac!att!cbnewse!cbnewsd!att-out!cbfsb!cbnewsg.cb.att.com!nh
  3. From: nh@cbnewsg.cb.att.com (nicholas.hounsome)
  4. Subject: Re: Is (p) instead of (p!=NULL) portable? 
  5. Message-ID: <1993Jan26.091708.11214@cbfsb.cb.att.com>
  6. Sender: news@cbfsb.cb.att.com
  7. Organization: AT&T
  8. References: <1993Jan25.125627.29030@ugle.unit.no>
  9. Date: Tue, 26 Jan 1993 09:17:08 GMT
  10. Lines: 23
  11.  
  12. From article <1993Jan25.125627.29030@ugle.unit.no>, by robert@alkymi.unit.no (Robert Schmidt):
  13. > In PC C's, the NULL pointer is defined with a bit pattern of all zero's,
  14. > and the constructs 
  15. >       if (p)
  16. > and
  17. >       if (!p)
  18. > checks for NULL and non-NULL respectively.  Is this portable to *all*
  19. > platforms?
  20. > Robert
  21.  
  22. It is NOT portable for C.
  23. It is portable for C++ which is the group that you have posted to -
  24. did you mean to?
  25.  
  26. #define NULL (void*)0
  27. if(p==NULL)
  28.  
  29. This is WRONG in C++ and right in C.
  30. (char*)0 is even worse in C++.
  31.  
  32.