Enumeration Constants
Enumeration constants are identifiers defined in enum type declarations. The iden-
tifiers are usually chosen as mnemonics to assist legibility. Enumeration constants
are of
int
type. 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 identifiers (enumerators) used must be unique within the scope of the enum
declaration. Negative initializers are allowed. See Enumerations for details of
enum
declarations.
Pointer Constants
A pointer or the pointed-at object can be declared with the
const
modifier.
Anything declared as a
const
cannot be have its value changed. It is also illegal
to create a pointer that might violate the nonassignability of a constant object.
Constant Expressions
A constant expression is an expression that always evaluates to a constant and
consists only of constants (literals) or symbolic constants. It is evaluated at com-
pile-time and it must evaluate to a constant that is in the range of representable
values for its type. Constant expressions are evaluated just as regular expressions
are.
Constant expressions can consist only of the following: literals, enumeration con-
stants, simple constants (no constant arrays or structures), sizeof operators.
Constant expressions cannot contain any of the following operators, unless the
operators are contained within the operand of a
sizeof
operator: assignment,
comma, decrement, function call, increment.
You can use a constant expression anywhere that a constant is legal.
MikroElektronika: Development tools - Books - Compilers
45
page
mikroC - C Compiler for Microchip PIC microcontrollers
mikroC
making it simple...