[PATCH] define [U]LLONG_{MIN,MAX} for C++11

Richard Smith richard at metafoo.co.uk
Sun Oct 27 11:43:27 PDT 2013


Sure, that works for me.
On 27 Oct 2013 11:28, "JF Bastien" <jfb at google.com> wrote:

> > It'd be nice to test that the values are actually correct, as well as
> that
> > they are in matching pairs. Something like:
> >
> > (unsigned char)SCHAR_MIN == (unsigned char)SCHAR_MAX + 1
> >
> > ... should do the trick.
>
> How about:
>
> _Static_assert(SCHAR_MAX == UCHAR_MAX/2, "");
> _Static_assert(SHRT_MAX == USHRT_MAX/2, "");
> _Static_assert(INT_MAX == UINT_MAX/2, "");
> _Static_assert(LONG_MAX == ULONG_MAX/2, "");
>
> Matched pairs make sure signed min/max are consistent, unsigned max
> are correct by casting all-ones, and the four I propose make sure
> signed max is correct.
>
> > Maybe:
> >
> > #else
> >
> > int LLONG_MIN, LLONG_MAX, ULLONG_MAX; // not defined
>
> Done.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131027/5470ae1f/attachment.html>


More information about the cfe-commits mailing list