Re: advantage of using typedefs




Emmanuel Delahaye wrote:
> junky_fellow@xxxxxxxxxxx a écrit :
> > I wanted to know what advantage do we get by typedefs ? Why we did not
> > declare
> > offset simply as
> > long off_t;
>
> It's often a portability issue. Imagine you want a type that hold the
> biggest possible unsigned integer.
>
> You will have this in C90:
>
> typedef unsigned long biggest_int_t;
>
> and that on C99:
>
> typedef unsigned long long biggest_int_t;
>
> With the help of some smart macros and #ifxxx directives, After a simple
> recompile, the type will automagically be corrected after a simple
> recompile of the project/lib or whatever.
>

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;
I believe unsigned long long should be highest possible integer type ?
Or am I wrong ?

Is there any other reason for doing that ?

.



Relevant Pages

  • Re: multiprocess mmapd space and condition-like variables (clarification please).
    ... It might not even be safe on a UP system, unless you declare the offset ... variable volatile. ... Barry Margolin, barmar@xxxxxxxxxxxx ...
    (comp.unix.programmer)
  • Re: Playing around with byte order
    ... code computes at runtime the byte-order of the unsigned integer, ... most people put all their standard header inclusions together, ... unsigned char GetByte(const unsigned * const pu, ... unsigned readLSBplus_offset(long unsigned number, size_t offset); ...
    (comp.lang.c)
  • Re: advantage of using typedefs
    ... >the biggest possible unsigned integer to hold offset) then why not declare ... Because then its size would vary from platform to platform, ... c90 implementation it would be an error. ...
    (comp.lang.c)
  • Re: ntp not synchronising
    ... >>there is an error message which indicates that the offset is too ... ntp will declare the server insane at 128msec... ...
    (comp.os.vms)
  • Re: advantage of using typedefs
    ... >>the biggest possible unsigned integer to hold offset) then why not declare ... > Because then its size would vary from platform to platform, ... Yes, but if you want the biggest unsigned integer type, you have to ...
    (comp.lang.c)