Type Qualifiers

The type qualifiers const and volatile are optional in declarations and do not actually affect the type of declared object.

Qualifier const

The qualifier const implies that a declared object will not change its value during runtime. In declarations with the const qualifier all objects need to be initialized.

The mikroBasic PRO for ARM treats objects declared with the const qualifier the same as literals or preprocessor constants. If the user tries to change an object declared with the const qualifier compiler will report an error.

For example:

const PI as byte = 3.14159

Qualifier volatile

The qualifier volatile implies that a variable may change its value during runtime independently from the program. Use the volatile modifier 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.

Copyright (c) 2002-2012 mikroElektronika. All rights reserved.
What do you think about this topic ? Send us feedback!
Want more examples and libraries? 
Find them on LibStock - A place for the code