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 Sun, May 29, 2016 at 03:54:29AM +0200, Kamil Rytarowski wrote:
 > On 29.05.2016 03:15, David Holland wrote:
 > > On Sat, May 28, 2016 at 03:45:35PM +0200, Kamil Rytarowski wrote:
 > >  > [iconv const mess]
 > > 
 > > So it appears that given
 > > 
 > >    size_t
 > >    iconv(iconv_t cd,
 > >            char **restrict src, size_t *restrict srcleft,
 > >            char **restrict dst, size_t *restrict dstleft);
 > >    size_t
 > >    __iconv_const(iconv_t cd,
 > >            const char **restrict src, size_t *restrict srcleft,
 > >            char **restrict dst, size_t *restrict dstleft);
 > > 
 > > one can do
 > > 
 > > #define iconv(cd, src, srcleft, dst, dstleft) \
 > >         _Generic(src, const char **: __iconv_const,  default: iconv) \
 > >                 (cd, src, srcleft, dst, dstleft)
 > > 
 > > and at least with the gcc5 in current it seems to match as intended.
 > > Plus if anything unexpected comes up #undef iconv makes the magic go
 > > away.
 > > 
 > > (Also, because implementing things as macros is not 100% benign it
 > > should maybe be disabled by default in strict posix mode.)
 > > 
 > > Anyone want to check if it works in clang?
 > 
 > 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.

 > How about the Solaris 11 move? Leave "extern" option for those who rally
 > want it and SUS/POSIX for others.

"extern" option?

-- 
David A. Holland
dholland%netbsd.org@localhost


Home | Main Index | Thread Index | Old Index