>> Why bother? Won't:
>> size_t foo = ~0UL;
>> do (~0ULL for C99)?
> Only if size_t is no larger than unsigned long int
(unsigned long
> long int for the ULL version). I don't think that's guaranteed.
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.
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.)
I think uintmax_t is another blemish in the standard, since it makes
certain kinds of innovation impossible. (For example, the presence of
uintmax_t makes it impossible to extend the compiler to recognize
uintXX_t as "unsigned integer type with at least XX bits" for all XX,
presumably with library support for integers over hardware-supported
sizes. At least without no longer, strictly, being a C compiler.)
/~\ The ASCII Mouse
\ / Ribbon Campaign
X Against HTML mouse at
rodents-montreal.org
/ \ Email! 7D C8 61 52 5D E7 2D 39 4E F1 31 3E E8 B3 27 4B