I know how enumerations work, but this looks odd to me

I understand the concept of enum and typdef. But what I don't understand is how the second code typedef relates to the enumeration under it. I would have that that the ; at the end of the typedef would have killed any potential relationship between the two.


This is defined in a separate header file.
 
typedef int myEnum;



1
2
3
4
5
6
7
typedef myEnum SomeType;

enum
{
    someType1 = 0,
    someType2 = 1,
};


Last edited on
how the second code typedef relates to the enumeration under it
It does not relates to that enum at all. There is too little context to say what that typedef is for.
I'll assume the header is included here, which would mean that SomeType is an int, for example it would be valid to do this:

 
SomeType num = 5;


It in no way relates to the enum below it.

EDIT:
Do note, however that an int and an enum member are more or less the same thing, so it would also be valid do this:

 
SomeType myType = someType1; //myType is an int with the value 0. 
Last edited on
See that's what I was thinking, that they can't relate. But, in the documentation for this SDK, it says that SomeType is an enum. And like you guys, I would think there is no way the enum can be a part of the typedef.

Also, if they are not, then what is the point of defining the enum? It has not been named thus you would not even be able to use it right?

Topic archived. No new replies allowed.