2.13.1 typedefs

The typedef keyword is used to declare an identifier as an alias for an existing type. Like all D type declarations, typedef is used outside of probe clauses in a declaration of the following form:

typedef existing-type new-type ;

where existing-type is any type declaration and new-type is an identifier to be used as the alias for this type. For example, the D compiler uses the following declaration internally to create the uint8_t type alias:

typedef unsigned char uint8_t;

You can use type aliases anywhere that a normal type can be used, such as the type of a variable or associative array value or tuple member. You can also combine typedef with more elaborate declarations such as the definition of a new struct, as shown in the following example:

typedef struct foo {
  int x;
  int y;
} foo_t;

In the previous example, struct foo is defined using the same type as its alias, foo_t. Linux C system headers often use the suffix _t to denote a typedef alias.