[cfe-dev] [libc++] xlocale usage portability issues
hhinnant at apple.com
Mon Oct 10 10:35:08 CDT 2011
On Oct 10, 2011, at 11:31 AM, aep wrote:
> I am right now patching musl to include the nessesary _l functions instead.
> David Chisnall has convinced me, it is worth the effort.
Great! I'll hold off committing any changes right now until the dust settles on your new _l functions.
>>> #pragma GCC system_header
>>> @@ -235,11 +235,11 @@ collate<_CharT>::do_hash(const char_type* lo,
>>> const char_type* hi) const
>>> size_t h = 0;
>>> const size_t sr = __CHAR_BIT__ * sizeof(size_t) - 8;
>>> - const size_t mask = size_t(0xF) << (sr + 4);
>>> + const size_t cmask = size_t(0xF) << (sr + 4);
>>> for(const char_type* p = lo; p != hi; ++p)
>>> h = (h << 4) + *p;
>>> - size_t g = h & mask;
>>> + size_t g = h & cmask;
>>> h ^= g | (g >> sr);
>>> return static_cast<long>(h);
>> Why does mask need to be renamed to cmask?
> good question, clang throws a weird error otherwise:
> include/__locale:238:23: error: expected unqualified-id
> const size_t mask = size_t(0xF) << (sr + 4);
> (it points at the = just in case my mail client screws up the indend)
It looks like this section of code could do with leading underscore treatment for all the local variables. We're probably being stepped on by macros.
More information about the cfe-dev