Keil™, An ARM® Company

Cx51 User's Guide

enum

The enum keyword defines set of constants of type char or type int depending on the range of values of the set. It is used as follows:

enum « tag » {name « = value », ...};

Where

tagis the name of the enum set.
nameis the name of an enum constant.
valueis the value to assign to the constant. If the value is missing, then it is assumed to be the value of the previous constant in the set + 1. The default value for the first constant in the list is 0.

Define an enum type in your program as follows:

enum tag name « = value »;

Where

tagis the name of the enum set.
nameis the name of the variable.
valueis the value to assign to the variable.

Refer to 1-Byte Scalars or 2-Byte Scalars for information regarding the format of enum constants.