c language based enumeration ----

Enumeration types are defined in the form of:

enum typeName{ valueName1, valueName2, valueName3, ...... };

enumIt is a new keyword, designed to define the enumerated type, which is its sole purpose in C language; typeNameis an enumerated type name; valueName1, valueName2, valueName3, ......a list of names corresponding to each value. Note that the last of ;not less.

Enumerations, and macros actually very similar: macro preprocessing stage name replaced by their corresponding values ​​in the enumeration phase of the compiler will replace the name into the corresponding value. We enumeration can be understood as a compilation phase of the macro.

Enumeration value that they do not occupy the data memory region (constant region, and global data stack area and the heap area), but directly to the command which is compiled, into the code area, it can not &obtain their addresses. This is the essence of enumeration.

Enumerated type variables need to be stored is an integer, and its length should be the same int, 4 bytes.

Guess you like

Origin www.cnblogs.com/xuey/p/12205760.html