HP C A.06.05 Reference Manual

Program Organization
Declarations
Chapter 220
Improving Portability
Type definitions can be used to compensate for differences in C compilers. For example:
#if SMALL_COMPUTER
typedef int SHORTINT;
typedef long LONGINT;
#elif
BIG_COMPUTER
typedef short SHORTINT;
typedef int LONGINT;
#endif
This is useful when writing code to run on two computers, a small computer where an int is
two bytes, and a large computer where an int is four bytes. Instead of using short, long, and
int, you can use SHORTINT and LONGINT and be assured that SHORTINT is two bytes and
LONGINT is four bytes regardless of the machine.
Simplifying Complex Declarations
You can use typedefs to simplify complex declarations. For example:
typedef float *PTRF, ARRAYF[], FUNCF();
This declares three new types called PTRF (a pointer to a float), ARRAYF (an array of floats),
and FUNCF (a function returning a float). These typedefs could then be used in declarations
such as the following:
PTRF x[5]; /* a 5-element array of pointers to floats */
FUNCF z; /* A function returning a float */