size_t

Tapani Tarvainen tarvaine at tukki.jyu.fi
Tue Jun 20 16:12:54 AEST 1989


In article <845 at cbnewsl.ATT.COM> dfp at cbnewsl.ATT.COM (david.f.prosser) writes:
>Section 4.1.5 of the pANS:
>
>	The types [defined in <stddef.h>] are ...
>
>		size_t
>
>	which is the unsigned integral type of the result of the sizeof
>	operator ...
>
>It is also defined in <stdio.h>, <stdlib.h>, <string.h> and <time.h>.

If this is all pANS says about it, TurboC's behaviour is legal.
As static objects can't exceed 64K, sizeof result will always
fit in unsigned int; but in huge model one can have a dynamic
array with more than 64K elements.  Therefore:

What should be done when one has an array whose indices may not fit
in an int?  Is there a suitable type for that in pANS?

If I use long, TC will warn that "Conversion may lose significant digits"
every time in models other than huge, not to mention that it is waste
of resources, but in huge model int won't do.
Suggestions, anyone?

(BTW, thank you David for informative answers, even though the info on
realloc was somewhat unfortunate: it seems I'll need an extra variable
for every pointer to the buffer that is reallocated.)


-- 
Tapani Tarvainen                 BitNet:    tarvainen at finjyu
Internet:  tarvainen at jylk.jyu.fi  -- OR --  tarvaine at tukki.jyu.fi



More information about the Comp.std.c mailing list