Re: advantage of using typedefs



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.
.



Relevant Pages

  • Re: advantage of using typedefs
    ... > integer to hold offset) then why not declare unsigned long long ... > Because then its size would vary from platform to platform, ... If you want the biggest possible ... But this thread was about why one would use typedefs, and one reason ...
    (comp.lang.c)
  • Re: DAW Configuration
    ... The biggest issue is always stability of the system and parts. ... The best advice I think I can give is: Invest in a good power supply, I won't run anything under 500Watts, and strongly recommend you do the same. ... It's just not worth the risk not buying a high end power supply, it's only a few dollars more and the gains in system stability under stress are substantial. ... The reason is simply that you want to reduce the work your primary HDD does by shifting part of the workload over to a second drive. ...
    (rec.audio.pro)
  • Re: Wie
    ... The feeling is that she is deliberately passing on events where ... That was *my* point, Dan - unless I have a reason to believe otherwise, I'm ... seen as having taken on the five biggest challenges available to her - a PGA ...
    (rec.sport.golf)
  • Re: Just to solve this once and for all.....
    ... Core suggests the biggest. ... Threads change and move on. ... "To argue with a person who has renounced the use of reason is like ...
    (uk.sport.football.clubs.rangers)
  • Re: Just to solve this once and for all.....
    ... Core suggests the biggest. ... Threads change and move on. ... "To argue with a person who has renounced the use of reason is like ...
    (uk.sport.football.clubs.rangers)