size_t + ptrdiff_t
Juan Manuel Cabo
juanmanuel.cabo at gmail.com
Tue Feb 21 17:52:59 PST 2012
I just went to see a standard draft (http://www.clc-wiki.net/wiki/the_C_Standard)
to make sure, and it is even more convoluted than just that, but essentially the
same. Basically it says that chars must be at least
8bits and that shorts and ints must be able to represent at least 16 bits.
Then the ranks of the types are related to each other like that:
rank(_Bool) < rank(char) < rank(short) < rank(int) < rank(long int) < rank(long long int)
but rank is about conversion, not size, so while rank is strictly ordered,
sizeof types might not.
I didn't find size_t other than as the type of the value of sizeof() expressions.
So, size_t is just standardized as the type of (sizeof(anystuff)).
I saw sizeof(long) <= sizeof(size_t) in a website, but not on the standard.
So the standard doesn't even guarantee size_t being more than other
types, or the bigger type.
On 02/21/2012 10:23 PM, Stewart Gordon wrote:
> On 21/02/2012 22:45, Juan Manuel Cabo wrote:
>> The C standard only guarantees that:
>> sizeof(char)<= sizeof(int)<= sizeof(long)<= sizeof(size_t)
> I'm surprised. I'd assumed that, under 16-bit DOS/Windows, a size_t would be 16 bits. But no. Could memory blocks 64K
> or larger actually be allocated under those systems?
More information about the Digitalmars-d