Re: advantage of using typedefs
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Sat, 28 Jan 2006 19:32:56 GMT
Mark McIntyre <markmcintyre@xxxxxxxxxxx> writes:
> On 28 Jan 2006 00:50:55 -0800, in comp.lang.c ,
> "junky_fellow@xxxxxxxxxxx" <junky_fellow@xxxxxxxxxxx> wrote:
>
> (concerning typdef'ing)
>
>>Thanx for your reply, Emmanuel. 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;
>
> Because then its size would vary from platform to platform, and on a
> c90 implementation it would be an error. Some implementations spell
> "long long" as "__int64", others don't support it at all etc etc.
>
>>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.
If you want a type whose size *doesn't* vary, you want
something like uint64_t (and if you need this in C90, see
<http://www.lysator.liu.se/c/q8/>). (I think most C90 implementations
these days provide 64-bit integer types under some name.)
BTW, C99 defines uintmax_t for precisely this purpose.
--
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
- 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
- advantage of using typedefs
- Prev by Date: Re: Question about the clc string lib
- Next by Date: Re: Second Highest number in an array
- Previous by thread: Re: advantage of using typedefs
- Next by thread: Re: advantage of using typedefs
- Index(es):
Relevant Pages
|