Subject: Re: Tiny patch to build abiword-0.9.2 with gcc-3.0 on Linux
From: Phil Stracchino (alaric@babcom.com)
Date: Thu Aug 16 2001 - 12:51:22 CDT
On Thu, Aug 16, 2001 at 01:29:59PM -0400, Dom Lachowicz wrote:
> Quoting Hubert Figuiere <hfiguiere@teaser.fr>:
>
> > According to Phil Stracchino <alaric@babcom.com>:
> > > --- abi/src/af/util/xp/ut_iconv.cpp.orig Thu Aug 16 01:10:46 2001
> > > +++ abi/src/af/util/xp/ut_iconv.cpp Thu Aug 16 01:10:42 2001
> > > @@ -137,7 +137,8 @@
> > > size_t UT_iconv( UT_iconv_t cd, const char **inbuf,
> > > size_t *inbytesleft, char **outbuf, size_t *outbytesleft )
> > > {
> > > - return iconv( cd, const_cast<ICONV_CONST char **>(inbuf),
> > > + const char **mybuf = inbuf;
> > > + return iconv( cd, mybuf,
> > > inbytesleft, outbuf, outbytesleft );
> > > }
> >
> > No. I won't apply this one as the ICONV_CONST is a trick to overcome
> > implementation variation accross the different iconv found in various
> > systems...
> > Applying your patch means breaking that.
>
> I agree with Hub - do not apply this patch for exactly these stated reasons.
> This was exactly why ICONV_CONST is there to resolve, but it seems that gcc3.0
> doesn't like it. Further, I've removed all iconv calls in our code, so now we
> only have this one place to fix (single point of failure principle). There has
> got to be a workaround for this, but if gcc3.0 is complaining about the "const"
> inside of the const_cast, we might have a problem unresolvable through our
> ICONV_CONST hack. Instead, I propose:
>
> char **mybuf = const_cast<char **>(inbuf);
> return iconv ( cd, mybuf, inbytesleft, outbuf, outbytesleft );
>
> This solution will safely remove the const, and will:
> 1) pass a char ** to older, broken iconvs
> 2) pass a char ** to newer iconvs which require a const char **, so we might
> catch a compiler warning about applying cv-equals without an explicit cast, but
> it's nothing serious.
>
> Tell me what you think, and if this works for anyone/everyone,
Perhaps configure should be trying to detect whether iconv requires a char
** or a const char **, and then simply #ifdef that line of code
accordingly? Or perhaps conditionally #define an appropriate casting
macro? I'd offer up an implementation, but my configure-fu is small.
-- Linux Now! ..........Because friends don't let friends use Microsoft. phil stracchino -- the renaissance man -- mystic zen biker geek alaric@babcom.com halmayne@sourceforge.net 2000 CBR929RR, 1991 VFR750F3 (foully murdered), 1986 VF500F (sold)
This archive was generated by hypermail 2b25 : Thu Aug 16 2001 - 12:51:26 CDT