Subject: Re: iconv(3) prototype
To: None <tech-userlevel@NetBSD.org>
From: KAMADA Ken'ichi <kamada@nanohz.org>
List: tech-userlevel
Date: 07/28/2004 18:53:01
At Wed, 28 Jul 2004 04:43:51 -0400 (EDT),
der Mouse <mouse@Rodents.Montreal.QC.CA> wrote:
>
> >> I've never understood why char ** is incompatible with
> >> const char **....
> > Briefly, [...]
> > "const char *" is a different type from "char *", thus converting
> > from "char **" to "const char **" is corresponding to (3).
>
> Well, yes; what I mean is, I don't understand why they picked rules
> that ended up with that effect. It should be possible to add
> qualifiers at any depth without producing an incompatible type.
If you could convert from "char **" to "const char **",
you can convert "const char *" to "char *" _without any cast_.
void
bad_func(const char *c_p)
{
char *p;
const char **c_pp;
c_pp = &p; /* If this were valid... */
*c_pp = c_p;
*p = 'X'; /* !!! */
}
--
KAMADA Ken'ichi <kamada@nanohz.org>