sizeof won't do what you want since commands is a type rather than some kind of aggregate. Since you're explicitly assigning a value in the middle, you cannot use the trick of computing from the value of the last enumerator either. Why do you need to know this count? Maybe there is another way that does not rely on such knowledge.