Hello gurus,

I know this question doesn't really belong to VC++ section, but here goes anyway....

I'd like to automatically detect how many elements my 'enum' data structure contains, something like

Code:
enum ENUM1 { A = -4, B, C, D, E };

printf("%d\n", MagicFunctionThatReturnsNumOfElementsInENUM1() );

??? sizeof(ENUM1) always returns 4

I guess I could write

Code:
int MagicFunctionThatReturnsNumOfElementsInENUM1()
{
return (E-A+1);
}
but then I gotta know the names of the first and last element of the enum...
Furthermore, this wouldn't work with enums like this

Code:
enum ENUM1 { A, B, C=56, D, E };
Any ideas? Is it even doable?