size_t

mark c anderson manderso at ugly.cs.ubc.ca
Tue Jun 20 15:49:49 AEST 1989


In article <934 at tukki.jyu.fi> tarvaine at tukki.jyu.fi (Tapani Tarvainen) writes:
>What exactly does pANS say about size_t?  In Turbo C 2.0 it is
>defined as unsigned int in all memory models, yet in huge model
>array indices are long.  Is this a bug?  

As has already been noted, size_t is defined as the "unsigned integral type
of the result of the sizeof operator", i.e. unsigned int (at least in this
case).

I'm not sure how Turbo C handles the huge memory model, but I was interested
to read how Microsoft deals with it:  if you cast the result of a sizeof
operation on a huge array to unsigned long, the correct result is produced.

A similar extension allows you to cast the result of a pointer-difference
operation on huge pointers to long, and get the desired result.

i.e.
	char huge *p, *q;
	long size;
	...
	size = (long) ( p - q );
---
Mark Anderson <manderso at ugly.cs.ubc.ca>
{att!alberta,uw-beaver,uunet}!ubc-cs!{good,bad,ugly}!manderso
Am I suspended in Gaffa?



More information about the Comp.std.c mailing list