[PATCH] Update newlib so that it passes libc++'s tests
JF Bastien
jfb@chromium.org
Wed Dec 18 21:32:00 GMT 2013
> > >and this is not quite ok. You're assuming that wchar_t is 4 bytes, but it
> > >isn't on all platforms. The fallbacks should take that into account,
> > >along the lines of
> > >
> > > #define WCHAR_MAX ((wchar_t)-1)
> > >
> > >
> > Unfortunately, this is not OK in general, as *_MAX defines are
> > required to be able to be used in preprocessor expressions, and
> > casts are not always allowed in them.
>
> Then it has to be done differently. The point is, you can't just set
> WCHAR_MAX to 0xffffffffu or 0x7fffffffu because it's wrong for some
> platforms. If the compiler doesn't provide the information, there has
> to be another way.
I may be wrong, but the hard-coded 32-bit size is a fallback if all
else fails. Really the compiler knows best, and that what
__WCHAR_{MIN,MAX}__ are there for. If all else fails then there is no
better way that I know (please let me know if there is).
Not that it's much of an argument but my patch isn't making things
*worst* with the 32-bit assumption (it was already there) it's merely
being correct when then compiler provides information. If anything
fixing that broken assumption may inadvertently break people who rely
on it today.
More information about the Newlib
mailing list