Subject: Re: Tiny patch to build abiword-0.9.2 with gcc-3.0 on Linux
From: Dom Lachowicz (dominicl@seas.upenn.edu)
Date: Thu Aug 16 2001 - 12:29:59 CDT
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,
Dom
/still in San Francisco, wishing he had a laptop :-)
This archive was generated by hypermail 2b25 : Thu Aug 16 2001 - 12:30:01 CDT