User manual
215
mikoPascal PRO for dsPIC30/33 and PIC24
MikroElektronika
Typedef Specier
The specier type introduces a synonym for a specied type. The type declarations are used to construct shorter or
more convenient names for types already dened by the language or declared by the user.
The specier type stands rst in the declaration:
type synonym = <type_denition>;
The type keyword assigns synonym to <type_denition>. The synonym needs to be a valid identier.
A declaration starting with the type specier does not introduce an object or a function of a given type, but rather a
new name for a given type. In other words, the type declaration is identical to a “normal” declaration, but instead of
objects, it declares types. It is a common practice to name custom type identiers with starting capital letter — this is
not required by the mikroPascal PRO for dsPIC30/33 and PIC24.
For example:
// Let’s declare a synonym for “byte”
type Distance = byte;
// Now, synonym “Distance” can be used as type identier:
var i : Distance; // declare variable i of byte
Type Qualiers
The type qualiers const and volatile are optional in declarations and do not actually affect the type of declared
object.
Qualier const
The qualier const implies that a declared object will not change its value during runtime. In declarations with the
const qualier all objects need to be initialized.
The mikroPascal PRO for dsPIC30/33 and PIC24 treats objects declared with the const qualier the same as literals
or preprocessor constants. If the user tries to change an object declared with the const qualier compiler will report
an error.
For example:
const PI : byte := 3.14159;
Qualier volatile
The qualier volatile implies that a variable may change its value during runtime independently from the program.
Use the volatile modier to indicate that a variable can be changed by a background routine, an interrupt routine, or I/O
port. Declaring an object to be volatile warns the compiler not to make assumptions concerning the value of an object
while evaluating expressions in which it occurs because the value could be changed at any moment.