Datasheet

Initializer expression can include previously declared enumerators. For example, in
the following declaration:
enum memory_sizes { bit = 1, nibble = 4 * bit, byte = 2 * nibble,
kilobyte = 1024 * byte };
nibble would acquire the value 4, byte the value 8, and kilobyte the value 8192.
Anonymous Enum Type
In our previous declaration, the identifier colors is an optional enumeration tag that
can be used in subsequent declarations of enumeration variables of the enum col-
ors
type:
enum colors bg, border; /* declare variables bg and border */
Like with struct and union declarations, you can omit the tag if no further variables
of this
enum type are required:
/* Anonymous enum type: */
enum { black, red, green, blue, violet, white } color;
Enumeration Scope
Enumeration tags share the same name space as structure and union tags. Enu-
merators share the same name space as ordinary variable identifiers:
int blue = 73;
{ // open a block
enum colors { black, red, green, blue, violet, white } c;
/* enumerator blue = 3 now hides outer declaration of int blue */
struct colors { int i, j; }; // ILLEGAL: colors duplicate tag
double red = 2; // ILLEGAL: redefinition of red
}
blue = 37; // back in int blue scope
153
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Language Reference
mikroC PRO for AVR
CHAPTER 5