Multiple attributes with the same enum labels result in a compile error [C++]
Created by: t-b
I'm trying to add DevEnum labels to TangoTest. But if I duplicate some of the labels I get compile errors ala
In file included from TangoTestStateMachine.cpp:38:0:
./TangoTest.h:79:2: error: redeclaration of ‘_A’
_A,
^~
In file included from TangoTestClass.cpp:48:0:
./TangoTest.h:79:2: error: redeclaration of ‘_A’
_A,
^~
./TangoTest.h:71:2: note: previous declaration ‘TangoTest_ns::_devenum_scalar_wEnum _A’
_A,
^~
./TangoTest.h:71:2: note: previous declaration ‘TangoTest_ns::_devenum_scalar_wEnum _A’
_A,
^~
An example is here -> https://github.com/t-b/TangoTest/tree/pogo-issue-duplicated-dev-num.
A couple of options spring to mind:
- Fold multiple enums being identical into one definition
- Use C++11 enum classes
- Add a surrounding namespace a la
namespace devenum_scalar_wEnum {
enum _devenum_scalar_wEnum {
_A,
_B,
_C,
_D,
} ;
typedef _devenum_scalar_wEnum devenum_scalar_wEnum;
}
I think option 3 is the most feasible one.