more about programming style
David M. Haynes
david at ecrhub.UUCP
Wed Jul 31 22:16:53 AEST 1985
> (Entering personal religious belief flammable mode)
>
> Typedefs are very nice when applied sparingly. Before you use
> typedefs, figure out why some intrinsic type won't do---perhaps
> the type will have to change on some machines, but once changed
> will be fine (e.g., if you need 24 bit integers, perhaps int is
> good enough, but maybe you need longs; perhaps you should use a
> typedef). Typedefs can also help if a complex type is used very
> often. Other than that they just it harder to figure out what's
> really happening.
>
> --
> In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)
> UUCP: seismo!umcp-cs!chris
> CSNet: chris at umcp-cs ARPA: chris at maryland
>
Around these parts, its a standard thing to use typedefs with structs.
ie: struct foo { }; <- shorter than normal
typedef struct foo FOO;
Now we can use a declaration like:
FOO record;
and know that since its capitalized its declared locally.
Its also fairly common to use a typedef stream (or numerous #defines)
to declare portable declarators.
ie:
typedef uint16 unsigned int; or #define uint16 unsigned int
typedef uint8 char; or #define uint8 char
This helps greatly when moving stuff from machine to machine.
--
--------------------------------------------------------------------------
David M. Haynes
Exegetics Inc.
..!utzoo!ecrhub!david
"I am my own employer, so I guess my opinions are my own and that of
my company."
More information about the Comp.lang.c
mailing list