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

JF Bastien jfb at google.com
Sun Oct 27 12:05:16 PDT 2013


Thanks, committed as r193506.

On Sun, Oct 27, 2013 at 11:43 AM, Richard Smith <richard at metafoo.co.uk> wrote:
> 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.



More information about the cfe-commits mailing list