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 const qualifier is used to indicate that variable value cannot be changed. Its value is set at initialization.

The mikroC PRO for AVR 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 double PI = 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