On Sun, 22 May 2016, Mouse wrote:
How can you
have the type of `size_t' wider than the widest unsigned
integer type in the respective revision of the language standard?
unsigned long long int isn't necessarily the largest integral type.
Nor do I see anything requiring size_t to be no larger than it.
Right, an implementation is free to add its own extended integer types
and `size_t' is not required to have the same width as one of the standard
integer types. There's a recommendation for `size_t' not to be wider than
`long' (unless necessary, heh), however that's just it, not mandatory.
uintmax_t, on the other hand, would be fine; it _is_
promised to be no
smaller than size_t (or any other unsigned integral type).
size_t foo = ~(uintmax_t)0;
should work fine to set foo to all-bits-set. (Since size_t is
unsigned, this will set it to be its largest possible value.)
But there's no `uintmax_t' in C89. If playing with casts already, I
think the most obvious solution is simply:
size_t foo = ~(size_t)0;
Maciej