Type Definitions
A type definition (a typedef statement) does not declare any data, but serves to define new identifiers for declaring data.
The syntax for a type definition is:
typedef declaration;
The new type name is the variable name in the declaration part
of the type definition. For example, the following defines a new type
called eggbox, using an existing type called egg:
typedef egg eggbox[DOZEN];
Variables declared using the new type name are equivalent to variables
declared using the existing type. For example, the following two declarations
for the variable fresheggs are equivalent:
eggbox fresheggs;
egg fresheggs[DOZEN];
A type definition can also have the following form:
typedef <<struct, union, or enum definition>> identifier;
An alternative type definition form is preferred for structures,
unions, and enumerations. The type definition form can be converted
to the alternative form by removing the typedef keyword and
placing the identifier after the struct, union, or enum keyword,
instead of at the end. For example, here are the two ways to define
the type bool:
enum bool { /* preferred alternative */
FALSE = 0,
TRUE = 1
};
OR
typedef enum {F=0, T=1} bool;
The first syntax is preferred because the programmer does not have to wait until the end of a declaration to determine the name of the new type.