I have a situation where I need two enums to hold one member of same name. My code is in C++, Using IAR Embeddedj Workbench IDE. The code snipped is as follows:
enum Port_e : uint32_t
{
PortA = 0,
PortB,
PortC,
PortD,
PortE,
PortF,
PortG,
PortH,
PortI,
PortJ,
PortK,
NONE
};
enum Pin_e : uint32_t
{
Pin0 = 0, Pin1, Pin2, Pin3, Pin4, Pin5, Pin6, Pin7,
Pin8, Pin9, Pin10, Pin11, Pin12, Pin13, Pin14, Pin15,NONE
};
if you notice here both enums have last member as NONE. This code does not compile. Gives Error as NONE is already defined.
Is there any way to make it build while keeping name as it is? I also do not want to change the type to "enum class" as it will break the rest of my application code.
Aucun commentaire:
Enregistrer un commentaire