Re: advantage of using typedefs



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.

--
A+

Emmanuel Delahaye
.



Relevant Pages

  • Re: advantage of using typedefs
    ... >biggest possible unsigned integer". ... >I notice that you snipped the direct question that I asked you. ... not smart enough to debug it." ...
    (comp.lang.c)
  • Re: advantage of using typedefs
    ... wrote:>Mark McIntyre writes: ... >>>biggest possible unsigned integer". ... Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." ...
    (comp.lang.c)
  • Re: advantage of using typedefs
    ... Its value is the biggest possible unsigned integer type. ... > Mark McIntyre. ...
    (comp.lang.c)