libiconv and iconv() prototype

Eric Blake ebb9@byu.net
Wed Dec 23 05:17:00 GMT 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Charles Wilson on 12/22/2009 8:25 PM:
> Err...by changing the prototype, doesn't that change the ABI?
> 
> -_EXFUN(iconv, (iconv_t, _CONST char **, size_t *, char **, size_t *));
> +_EXFUN(iconv, (iconv_t, char **, size_t *, char **, size_t *));

On the binary-compatibility perspective: I see no problem.  const char**
and char** are the same size, so older applications calling the newer
function will still function as if nothing had changed.   And as long as
the implementation doesn't modify the argument (which libiconv does not,
otherwise libiconv wouldn't have worked even when the const is present),
all that is lost by omitting the const is an opportunity for a compiler
optimization.  You are correct that the POSIX prototype is not
const-correct, since no sane implementation will ever modify the contents
of inbuf.  But it is specified without the const in POSIX iconv pre-dated
const-correctness issues.

On the compilation-compatibility perspective: yes, this is a
backwards-incompatible change - anyone that passed a const char** to iconv
will now have to add a cast to silence a compiler warning.  On the other
hand, such code was already non-portable because it conflicts with the
POSIX prototype, so adding the cast to such code is good for portability
anyways.

> So, are you advocating a new cygiconv-3.dll?  Or am I wrong, and this
> change does NOT affect the ABI?

I don't see any reason to bump to cygiconv-3.dll - it seems like keeping
things at cygiconv-2.dll should still work.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             ebb9@byu.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAksxp+QACgkQ84KuGfSFAYDDqgCgzLreqAg20Hx7ml0ZucjKdn9V
7hoAmQEae3eNyYxl2RC9OMKrt9TV5vvC
=UsST
-----END PGP SIGNATURE-----

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list