home > resources > c++ coding standard > online version

Enum Names

  • Labels All Upper Case with '_' Word Separators

Justification

  • This is the standard rule for enum labels.

Example 2-14. Enum Names Example

enum PinStateType
{
    PIN_OFF,
    PIN_ON,
};

Note

It's often useful to be able to say an enum is not in any of its valid states. Make a label for an uninitialized or error state. Make it the first label if possible.

Example 2-15. Invalid Enum States Example

enum { STATE_NONE, STATE_OPEN, STATE_RUNNING, STATE_DYING};