liveBook · Manning

Underlying type

As explained in Modern C, Third Edition

An underlying type is the integer type used to represent the values of a C enumeration.

An underlying type is the integer type used to represent a C enumeration. Without an explicit choice, the implementation adjusts it to hold every enumeration constant; this can produce platform-dependent signed or unsigned types. section 5.6.2

Use explicit underlying types when enumeration values may exceed signed int:

  • C23 permits enum wider : long, forcing long as the underlying type and giving its constants the enumeration type. section 5.6.2

How Modern C, Third Edition covers it

How deep it goes
Explains automatic adjustment, signedness variation, impossible ranges, and C23 syntax, while deferring deeper typeof treatment.
Examples
Uses wide, narrow, ambiguous large, and explicitly typed eInt, eSig, and e32 enumerations.
What you can do after
Evaluate enumeration definitions for portability and specify an underlying type when values or signedness could vary.
How it connects
Connects enumeration constants with integer types, signedness, fixed-width types, and typeof.

Also explained in

Compare how 2 books explain underlying type →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern C, Third Edition. The section links point to the parts of the book it draws on.