home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / c / 19511 < prev    next >
Encoding:
Text File  |  1993-01-10  |  1.1 KB  |  35 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!usc!howland.reston.ans.net!spool.mu.edu!uwm.edu!psuvax1!andrew
  3. From: andrew@astro.psu.edu (Andrew Wilcox)
  4. Subject: can a pointer cast to a void* be compared to (void*)0 ?
  5. Message-ID: <C0nzI2.CqM@cs.psu.edu>
  6. Sender: news@cs.psu.edu (Usenet)
  7. Nntp-Posting-Host: multiwave.astro.psu.edu
  8. Organization: Department of Astronomy and Astrophysics, Penn State University
  9. Distribution: comp
  10. Date: Mon, 11 Jan 1993 00:46:45 GMT
  11. Lines: 22
  12.  
  13. This may be a FAQ, but I didn't see it in Steve Summit's excellent
  14. list, so:
  15.  
  16. Can a pointer which has been cast to a void* be directly compared with
  17. a (void*)0 in ANSI C, or does the void* have to be cast back to the
  18. original type before the comparision?  I.e.,
  19.  
  20.      char* c = 0;
  21.      void* p = (void*) c;
  22.      if (p == 0)
  23.        printf( "yes\n" );
  24.  
  25. Is this program guaranteed to print "yes"?
  26.  
  27. I am writing a dynamic typing system for C, so this question is not
  28. just of idle curiousity.
  29.  
  30. Thanks all,
  31.  
  32. Andrew Wilcox
  33. Department of Astronomy & Astrophysics, Pennsylvania State University
  34. (awilcox@astro.psu.edu)
  35.