Re: advantage of using typedefs
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Sun, 29 Jan 2006 20:36:40 GMT
Mark McIntyre <markmcintyre@xxxxxxxxxxx> writes:
> On Sat, 28 Jan 2006 21:31:09 GMT, in comp.lang.c , Keith Thompson
> <kst-u@xxxxxxx> wrote:
>>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.
>
>>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".
>
> My point was that it will vary, and is thus a nonportable construct in
> terms of say file access. If all you care about is one platform, then
> no problem.
> But this thread was about why one would use typedefs, and one reason
> is to keep such platform specific stuff in a single place.
Of course it will vary. junky_fellow *specifically* asked about "the
biggest possible unsigned integer". Maybe that's not the best thing
to use for a file offset -- and if that was your point, you might have
said so.
But *if* you need the biggest possible unsigned integer, for whatever
reason, it's perfectly sensible to use a typedef for it (or, in C99,
to use the existing uintmax_t). There could be any number of reasons
you'd want that. Of course, any code using it would have to allow for
the fact that the size will vary from one platform to another.
I notice that you snipped the direct question that I asked you.
--
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: CBFalconer
- 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
- Re: advantage of using typedefs
- From: Keith Thompson
- Re: advantage of using typedefs
- From: Mark McIntyre
- advantage of using typedefs
- Prev by Date: Re: Can we cast an integer as (void *)x
- Next by Date: Re: NULL with representation other then all bits 0
- Previous by thread: Re: advantage of using typedefs
- Next by thread: Re: advantage of using typedefs
- Index(es):
Relevant Pages
|