8.9.1 Const Type Qualifier

The MPLAB XC32 C/C++ Compiler supports the use of the ANSI type qualifiers const and volatile.

The const type qualifier is used to tell the compiler that an object is read only and will not be modified. If any attempt is made to modify an object declared const, the compiler will issue a warning or error.

Usually a const object must be initialized when it is declared, as it cannot be assigned a value at any point at runtime. For example:

const int version = 3;

will define version as being an int variable that will be placed in the program memory, will always contain the value 3, and which can never be modified by the program.