C++ enumerations and compiler dependency
- by dougie
I currently have code with an enum where one value is set and the rest are left to be set by the compiler using the previous value +1, or so I hope.
Is this functionality within an enumerated type compiler dependant, an example is below to clarify.
enum FUNC_ERROR_CODE
{
FUNC_SUCCESS,
FUNC_ERROR_1 = 24,
FUNC_ERROR_2,
FUNC_ERROR_3
}
Is it safe to assume that FUNC_ERROR_2 will have the value 25 and FUNC_ERROR_3 will have the value 26, regardless of compliler used.
I'm coding this so as a function can return an integer value, 0 is always success and any other value can signify failure.