ABL electronic PIC16 Personal Computer User Manual


 
Typedef Specifier
Specifier typedef introduces a synonym for a specified type. You can use type-
def declarations to construct shorter or more meaningful names for types already
defined by the language or for types that you have declared. You cannot use the
typedef specifier inside a function definition.
The specifier
typedef stands first in the declaration:
typedef <type-definition> synonym
;
The typedef keyword assigns the
synonym
to the
<type-definition>
. The
synonym
needs to be a valid identifier.
Declaration starting with the
typedef specifier does not introduce an object or
function of a given type, but rather a new name for a given type. That is, the
typedef declaration is identical to “normal” declaration, but instead of objects, it
declares types. It is a common practice to name custom type identifiers with start-
ing capital letter — this is not required by C.
For example:
// Let's declare a synonym for "unsigned long int":
typedef unsigned long int Distance;
// Now, synonym "Distance" can be used as type identifier:
Distance i;
// declare variable i of unsigned long int
In typedef declaration, as in any declaration, you can declare several types at once.
For example:
typedef int *Pti, Array[10];
Here, Pti is synonym for type “pointer to int”, and Array is synonym for type
“array of 10
int elements”.
mikroC
- C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...
92
MikroElektronika:
Development
tools
-
Books
-
Compilers
page