C++ enumerations and compiler dependency
Posted
by
dougie
on Stack Overflow
See other posts from Stack Overflow
or by dougie
Published on 2011-06-27T12:08:23Z
Indexed on
2011/06/27
16:22 UTC
Read the original article
Hit count: 325
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.
© Stack Overflow or respective owner