Article View: comp.std.c
Article #255Re: size_t
From: mark c anderson
Date: Tue, 20 Jun 1989 05:49
Date: Tue, 20 Jun 1989 05:49
25 lines
1454 bytes
1454 bytes
In article <934@tukki.jyu.fi> tarvaine@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@ugly.cs.ubc.ca>
{att!alberta,uw-beaver,uunet}!ubc-cs!{good,bad,ugly}!manderso
Am I suspended in Gaffa?
Technical Details
Message-ID:
<2284@ubc-cs.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!att!alberta!ubc-cs!ugly.cs.ubc.ca!mandersoReferences:
<934@tukki.jyu.fi>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!att!alberta!ubc-cs!ugly.cs.ubc.ca!manderso From: manderso@ugly.cs.ubc.ca (mark c anderson) Newsgroups: comp.std.c Subject: Re: size_t Message-ID: <2284@ubc-cs.UUCP> Date: 20 Jun 89 05:49:49 GMT References: <934@tukki.jyu.fi> Sender: news@cs.ubc.ca Reply-To: manderso@ugly.cs.ubc.ca (mark c anderson) Organization: UBC Department of Computer Science, Vancouver, B.C., Canada Lines: 25