In a library I have come across a weird construction which serves as enum:
typedef struct SetControl
{
const static uint16_t RC_MODE_ERROR;
const static uint16_t RELEASE_CONTROL_SUCCESS;
const static uint16_t OBTAIN_CONTROL_SUCCESS;
const static uint16_t OBTAIN_CONTROL_IN_PROGRESS;
const static uint16_t RELEASE_CONTROL_IN_PROGRESS;
const static uint16_t RC_NEED_MODE_F;
const static uint16_t RC_NEED_MODE_P;
const static uint16_t IOC_OBTAIN_CONTROL_ERROR;
} SetControl;
The members are not initialized anywhere but even though, RC_MODE_ERROR
equals 0, RELEASE_CONTROL_SUCCESS
equals 1 and so on. I know because I have logged it with printf. I haven't seen anything like it so far. Why does it even work (I thought values will be initialized by random data by default, or 0)? Is there any add value from this over standard enum
?
What can I try next?