Subject: Re: iconv(3) prototype
To: Alan Barrett <email@example.com>
From: Andrew Brown <firstname.lastname@example.org>
Date: 07/29/2004 00:17:02
On Wed, Jul 28, 2004 at 04:48:48PM +0200, Alan Barrett wrote:
>On Wed, 28 Jul 2004, Andrew Brown wrote:
>> 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 *".
>You have that almost exactly backwards. Perhaps you should use cdecl?
>cdecl> explain const char ** x;
>declare x as pointer to pointer to const char
>cdecl> explain char * const * x;
>declare x as pointer to const pointer to char
>cdecl> explain char ** const x;
>declare x as const pointer to pointer to char
okay, then i was right the first time when i said to myself that i
shouldn't speak up because i was probably confusing myself.
suffice it to say that you can't pass "&x" to a function that expects
"const char **", where x is a "char *". ah...that's where the
confusing "char * const *" type pops up, which has const in the wrong
place (ie, the requisite one can be added, but the other can't be
|-----< "CODE WARRIOR" >-----|
email@example.com * "ah! i see you have the internet
firstname.lastname@example.org (Andrew Brown) that goes *ping*!"
email@example.com * "information is power -- share the wealth."