0

Hi, I have a list of named enums:

typedef enum EGCDevicePneumaticState { 
EUnknown,
ENotPresent,
ENotReady,
EPressureNotReady,
EFlowNotReady,
EReadyOn,
EReadyOFF,
NumberOfEGCDevicePneumaticState,
};

typedef enum EGCDeviceReadiness { 
EUnknown,
EReady,
EReadForPrep,
ENotReady,
NumberOfEGCDeviceReadiness,
};

typedef enum EGCDeviceRunState { 
EIdle,
EPreRun,
ERun,
EPostRun,
NumberOfEGCDeviceRunState,
};

typedef enum EGCDeviceThermalState { 
EUnknown,
ENotPresent,
EOff,
ENotReady,
EReady,
NumberOfEGCDeviceThermalState,
};

and I am getting errors like:

error C2365: 'EUnknown' : redefinition; previous definition was 'enumerator'
see declaration of 'EUnknown'
error C2365: 'EReady' : redefinition; previous definition was 'enumerator'
see declaration of 'EReady'
error C2365: 'ENotReady' : redefinition; previous definition was 'enumerator'
see declaration of 'ENotReady'

and so on, but these are named, doesn't that mean I can re-use the names for other enums?

Edited by hanvyj: n/a

2
Contributors
2
Replies
5
Views
6 Years
Discussion Span
Last Post by hanvyj
1

You can't use the same name of the enum's within the same scope.

when you do this:

typedef enum A {
 enum1,
 enum2,
 enum3
};

its about the same as doing this:

const int enum1 = 0;
const int enum2 = 1;
const int enum3 = 2;

So you can see that what your doing is redefining the same variable many times in the same scope.

0

Ok, yeah I just tested it, I just assumed they were more high-level structures, I guess I will just have to put something before the name, like:

typedef enum A {
      Aenum1,
      Aenum2,
      Aenum3
      };

thanks, the msdn section on enums should say something about that! (though I might of missed it)

Edited by hanvyj: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.