Crossware

Table of Contents        Previous topic       Next topic       

C COMPILER->Compiler Data Formats->enum

The compiler will minimise the size of enum variables and preferably make them unsigned in accordance with the range of values in the enumeration list. This strategy results in the most efficient code.

An enum variable may therefore consist of 1, 2 or 4 bytes.  For example:

enum evals { ea, eb, ec, ed, ef };
enum eValue;

enum ebigvals { eba = -123456, ebb = 0, ebc =  76 };
enum eBigVal;

Variable eValue declared above only needs to represent values 0 to 4 and so will be represented as an unsigned char in any arithmetic operations.  On the other hand variable eBigVal must represent values from 123456 to +76 and so will be represented as a signed long in any arithmetic operations.