Subject: Re: iconv(3) prototype
To: None <tech-userlevel@NetBSD.org>
From: James K. Lowden <jklowden@schemamania.org>
List: tech-userlevel
Date: 08/03/2004 08:50:49
On Mon, 02 Aug 2004 13:08:05 +0200, Pavel Cahyna
<pavel.cahyna@st.ms.mff.cuni.cz> wrote:
> On Tue, 27 Jul 2004 05:34:14 +0000, James K. Lowden wrote:
> 
> > On Mon, 26 Jul 2004, christos@zoulas.com (Christos Zoulas) wrote:
> >> 
> >> We have:
> >> 
> >> size_t
> >> iconv(iconv_t, const char **restrict, size_t *restrict,
> >>     char **restrict, size_t *restrict);
> >> 
> >> X/Open wants:
> >> 
> >> size_t
> >> iconv(iconv_t, char **restrict, size_t *restrict,
> >>     char **restrict, size_t *restrict);
> >> 
> >> What gives?
> > 
> > Not to start anything, but fwiw GNU defines theirs as const, too.  And
> 
> Really? Quoting from /usr/include/iconv.h :
> 
> extern size_t iconv (iconv_t __cd, char **__restrict __inbuf,
>                      size_t *__restrict __inbytesleft,
>                      char **__restrict __outbuf,
>                      size_t *__restrict __outbytesleft);
> (this is on Debian 3.0 - Woody, glibc-2.2.5-6).

(What is the world use is it to declare formal parameters with two leading
underscores?  Whose namespace are they protecting?)

I was going by what I'm using in pkgsrc:

$ pkg_info libiconv |grep ^Info; grep ^extern /usr/pkg/include/iconv.h
|grep inbytes

Information for libiconv-1.9.1nb2:
extern size_t iconv (iconv_t cd, const char* * inbuf, size_t *inbytesleft,
char* * outbuf, size_t *outbytesleft);

However, it seems that due to C's type-conversion rules, there's simply no
good way declare this function (in light of the standard).  It seems the
consensus is to adhere to the standard, warts and all.  

--jkl