tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: iconv(3) protype mismatch with POSIX
On 16.06.2016 20:16, David Holland wrote:
> On Thu, Jun 16, 2016 at 12:27:47PM +0200, Kamil Rytarowski wrote:
> > > > This is an interesting exercise to use C11.. however:
> > > > 1. Not all ports moved to gcc 4.9+,
> > > > 2. pcc doesn't support it,
> > > > 3. it won't work as a valid and acceptable C++ code.
> > > > 4. Many software expects system headers to be C89, GNU89 etc, and
> > > > doesn't request C11.
> > >
> > > None of that matters, it just needs to be wrapped in suitable ifdefs.
> >
> > All of them matters to me and C11 in a public-header is no-go.
>
> Uh, I don't follow. What's wrong with
>
> #if defined(_NETBSD_SOURCE_) && \
> defined(__GNUC_PREREQ__(5,3)) && !defined(__cplusplus)
> (polymorphic iconv as suggested)
> #else
> (posix iconv)
> #endif
>
> ?
>
I understood that the default-fallback one will be the non complainant one.
Is it going to be a temporary solution?
_Generic is available since GCC-4.9, a more portable implementation is
to use __builtin_constant_p + __builtin_choose_expr... however there are
still plenty of compilers without support for similar features (like PCC).
In C++ there is a polymorphic solution out-of-the-box in C++98 with
function overloading.
> > > "extern" option?
> >
> > NAME
> >
> > iconv - code conversion function
> >
> > SYNOPSIS
> >
> > Default
> >
> > #include <iconv.h>
> >
> > extern size_t iconv(iconv_t cd, const char **restrict inbuf,
> > size_t *restrict inbytesleft, char **restrict outbuf,
> > size_t *restrict outbytesleft);
> >
> >
> > SUSv3
> > #include <iconv.h>
> >
> > size_t iconv(iconv_t cd, char **restrict inbuf,
> > size_t *restrict inbytesleft, char **restrict outbuf,
> > size_t *restrict outbytesleft);
>
> Uh, I have no idea what you're getting at.
>
I'm not familiar with opensolaris development.. I got an example:
#ifdef _XPG6
extern size_t iconv(iconv_t, char **_RESTRICT_KYWD,
size_t *_RESTRICT_KYWD, char **_RESTRICT_KYWD,
size_t *_RESTRICT_KYWD);
#else
extern size_t iconv(iconv_t, const char **_RESTRICT_KYWD,
size_t *_RESTRICT_KYWD, char **_RESTRICT_KYWD,
size_t *_RESTRICT_KYWD);
#endif
--
https://github.com/illumos/illumos-gate/blob/5a4ef21a18dfdc65328821a265582d03e85a97c9/usr/src/head/iconv.h
Assuming that the POSIX version has been already proposed as the default
one, how about:
#if defined(_NETBSD_SOURCE) && defined(_CONSTIFIED_ICONV)
size_t iconv(iconv_t, const char ** __restrict,
size_t * __restrict, char ** __restrict,
size_t * __restrict);
#else
size_t iconv(iconv_t, const char ** __restrict,
size_t * __restrict, char ** __restrict,
size_t * __restrict);
#endif
It will work for all c(89+)/c++(98+)/objc/.. compilers.
With that we could build software with additional CPPFLAGS defines when
needed.
Next step is to detect what fails to build in pkgsrc and adjust it
accordingly.
Home |
Main Index |
Thread Index |
Old Index