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

JF Bastien jfb at google.com
Sun Oct 27 11:28:25 PDT 2013


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



More information about the cfe-commits mailing list