Re: Cast abuse



On Tue, 20 November 13:09 Peter Bloomfield wrote:
> On 2001.11.20 05:38 Pawel Salek wrote:
> ...
>> glibc-devel-2.2.4-19:/usr/include/iconv.h contains:
>> 
>> extern size_t iconv (iconv_t __cd, char **__restrict __inbuf,
>>                      size_t *__restrict __inbytesleft,
>>                      char **__restrict __outbuf,
>>                      size_t *__restrict __outbytesleft);
>> 
>> I do not know what '__restrict' means (anybody knows?) but it does not 
>> appear to be equivalent to 'const'.
>> 
>> /Pawel
> 
> That's the version I have, and gcc complains about passing from an 
> incompatible pointer type if when inbuf is passed from a const char **.

Hmmm.  Given libc seems to define a macro to const or nothing during 
configuring, I wonder if this is something that varies between linux distros.  
Furthermore, given that SUSv2 says that inbuf is a const char ** I'd say the 
distros that don't have const are wrong in this respect - at least if 
standards compliance matters.

> The __restrict stuff is a mystery to me, but it doesn't look as though it 
> can be defined so as to change the declaration to a const char **. So until 
> the header file gets updated, I believe we need the cast.

I think restrict might be a new keyword of ISO C99, but I don't have access to 
the new standard to check.

I strongly suggest the approach of defining a BAD_CAST macro either to the 
required cast or a null string.  Have configure detect if it is required or 
not.

Brian



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]