2. Embedded SQL for C : C Variables and Data Types : Variable and Type Declarations : Enumerated Integer Types
 
Share this page                  
Enumerated Integer Types
An enumerated type declaration, enum, is treated as an integer declaration. The syntax of an enumerated type declaration is:
enum [enum_tag]
       { enumerator [= integer_literal]
       {, enumerator [= integer_literal]} } [enum_vars];
The outermost braces ({ and }) represent braces that you have to type.
Note:   
If you use the enum_tag, the list of enumerated literals (enumerators) and enum variables (enum_vars) is optional, like a structure tag without a body. The two declarations that follow are equivalent. The first declaration declares an enum_tag, while the second declaration uses that tag to declare a variable.
First declaration:
enum color {RED, WHITE, BLUE};/* Tag,
     no variable */
enum color col; /* Tag, no body,
     has variable */
Second declaration:
enum color {RED, WHITE, BLUE} col;/* Tag, body,
has variable */
If you do not use the enum_tag, the declaration must include a list of enumerators, in the same way as a structure declaration.
You can use the enum declaration with any other variable declaration, type declaration, or storage class. For example, the following declarations are all legal:
typedef enum {dbTABLE, dbCOLUMN, dbROW, dbVIEW,
     dbGRANT} dbOBJ;
 dbOBJ obj, objs[10];
 extern dbOBJ *obj_ptr;
Enumerated variables are treated as integer variables and enumerated literals are treated as integer constants.