Uploaded September 2026 | Updated November 2026, 1 day ago
Learn about Fixed Underlying Types for Enumerations in C and understand how C23 allows us to explicitly specify the underlying type of an Enum.
In this tutorial, we first review an Enum example using Traffic Light Colors and understand the difference between an Enum Type and its Underlying Type. A variable can have a type such as enum TrafficLightColor, while the Enumeration itself uses an underlying integer type to represent its values.
We then discuss how the underlying type can depend on the compiler implementation when a Fixed Underlying Type is not explicitly specified.
Next, we explore the C23 feature that allows us to specify a Fixed Underlying Type while defining an Enumeration. Using the colon syntax, we explicitly specify types such as unsigned char, int, unsigned int, char, or long long int as the underlying type.
Using the sizeof operator, we compare the size of an Enum with the size of its specified underlying type. We also compare this with an Enum where the underlying type is not explicitly specified.
The tutorial also explains that Enumerator Values must fit within the range of the specified underlying type. For example, when an unsigned type is specified, a negative Enumerator Value falls outside that type's range.
Finally, we discuss situations where controlling Enum representation and value range can be useful, including binary data formats, hardware interfaces, and communication protocols. We also note that Fixed Underlying Types for Enums are a C23 feature and compiler support may vary.
Our Website
LearningLad.com
Social Media
Facebook facebook.com/LearningLad
Twitter twitter.com/LearningLadEdu
Instagram instagram.com/LearningLadOfficial
Learn about Fixed Underlying Types for Enumerations in C and understand how C23 allows us to explicitly specify the underlying type of an Enum.
In this tutorial, we first review an Enum example using Traffic Light Colors and understand the difference between an Enum Type and its Underlying Type. A variable can have a type such as enum TrafficLightColor, while the Enumeration itself uses an underlying integer type to represent its values.
We then discuss how the underlying type can depend on the compiler implementation when a Fixed Underlying Type is not explicitly specified.
Next, we explore the C23 feature that allows us to specify a Fixed Underlying Type while defining an Enumeration. Using the colon syntax, we explicitly specify types such as unsigned char, int, unsigned int, char, or long long int as the underlying type.
Using the sizeof operator, we compare the size of an Enum with the size of its specified underlying type. We also compare this with an Enum where the underlying type is not explicitly specified.
The tutorial also explains that Enumerator Values must fit within the range of the specified underlying type. For example, when an unsigned type is specified, a negative Enumerator Value falls outside that type's range.
Finally, we discuss situations where controlling Enum representation and value range can be useful, including binary data formats, hardware interfaces, and communication protocols. We also note that Fixed Underlying Types for Enums are a C23 feature and compiler support may vary.
Our Website
LearningLad.com
Social Media
Facebook facebook.com/LearningLad
Twitter twitter.com/LearningLadEdu
Instagram instagram.com/LearningLadOfficial










