Enumerations

An enumeration is an integer field, whose possible values consists of a set of named integer constants.

enum BOOL { FALSE, TRUE };

This declaration introduces a type BOOL, which can accept values 0 (FALSE) and 1 (TRUE).

The enumeration declaration may be preceded by a size specifier, which is one of the keywords byte, word, dword, or qword. If the size keyword is omitted, FlexHEX assumes the size is 32-bit, so the above definition is equivalent to

dword enum BOOL { FALSE, TRUE };

You can assign numeric values explicitly:

enum BOOL { TRUE=1, FALSE=0 };

Numbers are decimal; in order to specify a hexadecimal value use the C-style notation:

byte enum MEDIA_TYPE { Floppy_35_144   = 0xF0,
                       Floppy_525_12   = 0xF9,
                       Floppy_525_180  = 0xFC,
                       Floppy_525_360  = 0xFD,
                       Floppy_525_160  = 0xFE,
                       Floppy_525_320  = 0xFF,
                       Hard_Disk       = 0xF8 };

Anonymous Enumerations

It is not necessary to declare a new enumeration type in order to define an enumeration type field. An anonymous enumeration may be used wherever a type name is expected and is declared as an enumeration type without the type name:

struct DocumentRecord {
  FILETIME CreationTime;
  enum { Complete, NeedsReview, OutOfDate } Status;
  char szName[];
};