[cfe-dev] [libc++] xlocale usage portability issues

Howard Hinnant hhinnant at apple.com
Tue Oct 11 07:25:00 PDT 2011


On Oct 11, 2011, at 5:12 AM, aep wrote:

>>> On OS X catopen() returns a pointer.  Perhaps a C-style cast is the
>>> way to go here.
> 
> i changed it. let's see if the attached patch works for you.
> This works for me, if i additionally uncomment the usings.
> 
> 
>> I'll analyze this later today as you suggested.
> 
> 
> No point in checking any further, musl is just missing some C99 feature :(
> So this has to be fixed in musl.
> 
> I still wonder why this compiles anyway. Probably it will throw undefined references later?
> Oh well, we'll see after i fixed musl.
> 
> 
> 
>>> Does __mask work for you instead?  And while you're at it can you
>>> prefix every local variable in here with "__"?
> 
> 
> done
> <0001-portability-fixes-for-generic-libc.patch>_______________________________________________

This patch looks good to me except for the casting in messages<_CharT> in <locale>:

../include/locale:3719:21: error: cannot cast from type 'catalog' (aka 'int') to pointer type 'nl_catd' (aka '__nl_cat_d *')
    nl_catd __cat = static_cast<nl_catd>(__c);
                    ^~~~~~~~~~~~~~~~~~~~~~~~~
../include/locale:3735:21: error: cannot cast from type 'catalog' (aka 'int') to pointer type 'nl_catd' (aka '__nl_cat_d *')
    nl_catd __cat = static_cast<nl_catd>(__c);
                    ^~~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.

For me, nl_catd is a pointer.  The only way to make both of us happy is to replace the reinterpret_cast with a C (cast)expression.

Howard




More information about the cfe-dev mailing list