home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!usc!howland.reston.ans.net!spool.mu.edu!uwm.edu!psuvax1!andrew
- From: andrew@astro.psu.edu (Andrew Wilcox)
- Subject: can a pointer cast to a void* be compared to (void*)0 ?
- Message-ID: <C0nzI2.CqM@cs.psu.edu>
- Sender: news@cs.psu.edu (Usenet)
- Nntp-Posting-Host: multiwave.astro.psu.edu
- Organization: Department of Astronomy and Astrophysics, Penn State University
- Distribution: comp
- Date: Mon, 11 Jan 1993 00:46:45 GMT
- Lines: 22
-
- This may be a FAQ, but I didn't see it in Steve Summit's excellent
- list, so:
-
- Can a pointer which has been cast to a void* be directly compared with
- a (void*)0 in ANSI C, or does the void* have to be cast back to the
- original type before the comparision? I.e.,
-
- char* c = 0;
- void* p = (void*) c;
- if (p == 0)
- printf( "yes\n" );
-
- Is this program guaranteed to print "yes"?
-
- I am writing a dynamic typing system for C, so this question is not
- just of idle curiousity.
-
- Thanks all,
-
- Andrew Wilcox
- Department of Astronomy & Astrophysics, Pennsylvania State University
- (awilcox@astro.psu.edu)
-