Article View: comp.lang.c.moderated
Article #2489Re: Annotations on K&R II
From: Konrad Schwarz
Date: Thu, 04 Apr 1996 00:56
Date: Thu, 04 Apr 1996 00:56
23 lines
1664 bytes
1664 bytes
In article <4jr73o$h87@solutions.solon.com>, jcoffin@rmii.com (Jerry Coffin) writes: |> While `char *' and `void *' are not the same, they are required to have the |> same representation. (The general idea seems to be that if you pass one in |> place of the other, it probably shouldn't cause a problem, but they never |> quite state that explicitly. I presume this was an attempt at enforcing |> compatibility with older libraries that expected a `char *' where a `void *' |> is now indicated.) My understanding is that a conversion to a (void *) followed by a conversion to the original pointer type is the identity mapping; in other words, the mapping a C compilers uses between (void *) and any other pointer type is bijective. I don't know what you mean with representation; note however that T1 *p; *(T2 **) &p == (T2 *) p is not necessarily true, even, I think, if T1 or T2 is void. This is the reason why casting the comparison function argument of qsort to a function of two void pointers even if the actual argument is a function of two pointers to non-void is non-conforming, since the compiler now has no place to insert the pointer-conversion code. Konrad Schwarz
Technical Details
Message-ID:
<4jv6o8$coj@solutions.solon.com>Path:
arc1-ca.pugleaf.net!solon.com!not-for-mailReferences:
<4jq1eq$a3c@solutions.solon.com> <4jr73o$h87@solutions.solon.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail From: schwarz@mips.complang.tuwien.ac.at (Konrad Schwarz) Newsgroups: comp.lang.c.moderated Subject: Re: Annotations on K&R II Date: 3 Apr 1996 18:56:40 -0600 Organization: TU Wien Sender: clc@solutions.solon.com Approved: clc@solutions.solon.com Message-ID: <4jv6o8$coj@solutions.solon.com> References: <4jq1eq$a3c@solutions.solon.com> <4jr73o$h87@solutions.solon.com> NNTP-Posting-Host: solutions.solon.com