MISRAC++2023-10.2.1 (C++ only)
In this section:
Synopsis
(Required) An enumeration shall be defined with an explicit underlying type
Enabled by default
Yes
Severity/Certainty
Medium/High

Full description
Using an explicit underlying type ensures that the type is obvious to the user and not implicit int or implementation defined.
Coding standards
This check does not correspond to any coding standard rules.
Code examples
The following code example fails the check and will give a warning:
enum class Example // Non-compliant (implementation defined type)
{
EO = 1,
E1 = 2,
E2 = 4
};
The following code example passes the check and will not give a warning about this issue:
enum class Example : unsigned char // Compliant
{
EO = 1,
E1 = 2,
E2 = 4
};