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 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.

I'm unsure what will happen with all these tools to detect system
capabilities.

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


Home | Main Index | Thread Index | Old Index