User manual

Table Of Contents
184
mikoC PRO for PIC32
MikroElektronika
Enumeration Constants
Enumeration constants are identiers dened in enum type declarations. The identiers are usually chosen as mnemonics
to contribute to legibility. Enumeration size is calculated according to the enumerators (enumeration elements). They
can be used in any expression where integer constants are valid.
For example:
enum weekdays { SUN = 0, MON, TUE, WED, THU, FRI, SAT };
The identiers (enumerators) used must be unique within the scope of the enum declaration. Negative initializers are
allowed. See Enumerations for details about enum declarations.
Pointer Constants
A pointer or pointed-at object can be declared with the const modier. Anything declared as const cannot change its
value. It is also illegal to create a pointer that might violate a non-assignability of the constant object.
Consider the following examples:
int i; // i is an int
int * pi; // pi is a pointer to int (uninitialized)
int * const cp = &i; // cp is a constant pointer to int
const int ci = 7; // ci is a constant int
const int * pci; // pci is a pointer to constant int
const int * const cpc = &ci; // cpc is a constant pointer to a constant int
The following assignments are legal:
i = ci; // Assign const-int to int
*cp = ci; // Assign const-int to
// object-pointed-at-by-a-const-pointer
++pci; // Increment a pointer-to-const
pci = cpc; // Assign a const-pointer-to-a-const to a
// pointer-to-const
The following assignments are illegal:
ci = 0; // NO--cannot assign to a const-int
ci--; // NO--cannot change a const-int
*pci = 3; // NO--cannot assign to an object
// pointed at by pointer-to-const.
cp = &ci; // NO--cannot assign to a const-pointer,
// even if value would be unchanged.
cpc++; // NO--cannot change const-pointer
pi = pci; // NO--if this assignment were allowed,
// you would be able to assign to *pci
// (a const value) by assigning to *pi.
Similar rules are applayed to the volatile modier. Note that both const and volatile can appear as modiers
to the same identier.