Subject: Re: iconv(3) prototype
To: der Mouse <mouse@Rodents.Montreal.QC.CA>
From: Andrew Brown <atatat@atatdot.net>
List: tech-userlevel
Date: 07/28/2004 09:48:40
On Wed, Jul 28, 2004 at 04:43:51AM -0400, der Mouse 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 i understand this properly (seebs?), it's like this:

   "const char **" is a pointer to a constant pointer to a character.
   "char * const*" is a pointer to a pointer to a constant character.
   the former is in the prototype.  the latter is the type end up with
   when you take the address of x, where x is a "const char *".

>> System A declares foo() as: void foo(char **);
>> System B declares foo() as: void foo(const char **);
>
>> If we wish to call it without warnings, we need to write as: [#if]
>
>Or, actually,
>
>	foo((void *)&str);
>
>provided both systems provide prototypes.

warning: cast discards qualifiers from pointer target type

-- 
|-----< "CODE WARRIOR" >-----|
codewarrior@daemon.org             * "ah!  i see you have the internet
twofsonet@graffiti.com (Andrew Brown)                that goes *ping*!"
werdna@squooshy.com       * "information is power -- share the wealth."