Re: advantage of using typedefs
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Sat, 28 Jan 2006 21:31:09 GMT
Mark McIntyre <markmcintyre@xxxxxxxxxxx> writes:
> On Sat, 28 Jan 2006 19:32:56 GMT, in comp.lang.c , Keith Thompson
> <kst-u@xxxxxxx> wrote:
>>Mark McIntyre <markmcintyre@xxxxxxxxxxx> writes:
>>> On 28 Jan 2006 00:50:55 -0800, in comp.lang.c ,
>>> "junky_fellow@xxxxxxxxxxx" <junky_fellow@xxxxxxxxxxx> wrote:
>>>
>>>>I believe unsigned long long should be highest possible integer type ?
>>>>Or am I wrong ?
>>>
>>> You're right, but the size of long long varies from platform to
>>> platform
>>
>>Yes, but if you want the biggest unsigned integer type, you have to
>>accept that its size is going to vary.
>
> ... which was my point.
Then I'm confused. junky_fellow's question was:
But if this is the case (ie we need the biggest possible unsigned
integer to hold offset ) then why not declare unsigned long long
offset
and you replied:
Because then its size would vary from platform to platform, and on
a c90 implementation it would be an error.
The second point is valid (except for the many C90 implementations
that provide "long long" as an extension), but I don't see what you're
getting at with the first point. If you want the biggest possible
unsigned integer, its size *will* vary from platform to platform, but
you presented the variation in size as a reason not to use "unsigned
long long".
(And C99 allows extended integer types, so unsigned long long isn't
necessarily the longest unsigned integer type. unsigned long long
could be 64 bits, and uintmax_t could be 128 bits.)
Either you want unsigned long long (whose size will vary, and which
may not exist in a C90 implementation), or you want the largest
unsigned integer type (whose size will vary), or you want an unsigned
type that's exactly 64 bits (which probably exists, but it's not
guaranteed in either C90 or C99). For the second and third cases, a
typedef is reasonable -- and C99's <stdint.h> provides uintmax_t and
uint64_t, respectively. For the first case, if you specifically want
unsigned long long for some reason, a typedef would be silly. Mark,
without going back to the question of what point you were making
upthread, is there anything in this paragraph you disagree with?
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.
- Follow-Ups:
- Re: advantage of using typedefs
- From: Mark McIntyre
- Re: advantage of using typedefs
- From: Jordan Abel
- Re: advantage of using typedefs
- References:
- advantage of using typedefs
- From: junky_fellow@xxxxxxxxxxx
- Re: advantage of using typedefs
- From: Emmanuel Delahaye
- Re: advantage of using typedefs
- From: junky_fellow@xxxxxxxxxxx
- Re: advantage of using typedefs
- From: Mark McIntyre
- Re: advantage of using typedefs
- From: Keith Thompson
- Re: advantage of using typedefs
- From: Mark McIntyre
- advantage of using typedefs
- Prev by Date: Re: Question about the clc string lib
- Next by Date: Re: Casting return value to fit within constraints of error values (portability)
- Previous by thread: Re: advantage of using typedefs
- Next by thread: Re: advantage of using typedefs
- Index(es):
Relevant Pages
|