Enum declaration with specified underlying type

Hi everyone,

since C++11 you are allowed to declare your enum with a specified underlying type.

Now I have a 433MHz remote that sends codes that the RCSwitch library decodes as unsigned long integers. For the rest of the programm I wanted to do a switch-case over these values and have them in a humanly readable form. So I decided to create an enum like this:

enum class Remote433Codes : unsinged long {
    Up      = 1913064181,
    Down    = 1913062651,
    Left    = 1913063671,
    Right   = 1913063161,
    Center  = 1913063416,
    Button1 = 1913062396,
    Button2 = 1913066986,
    Button3 = 1913063926,
    Power   = 1913066731,
};

which yields the following three error messages:

warning: elaborated-type-specifier for a scoped enum must not use the 'class' keyword
error: use of enum 'Remote433Codes' without previous declaration
error: expected unqualified-id before ':' token

To me the warning indicates that the avr-g++ toolchain I am using (my PIO uses 7.3.0, I think) does not fully support enum classes and specified types?
The errors led me to various posts where the function prototype generation of the arduino IDE caused this issue. The enum is currently not used anywhere but just included in my main.

Is there some unknown function generation happening that causes this issue? Or does the compiler not support that feature?

Anyway, thanks to anyone taking the time to help me with this.

Why the use of class in the enum declaration ?

Does it help if you spell unsigned correctly ?

2 Likes

It's a scoped enum

Why yes, yes it does :thinking:

1 Like

Oh man, this is embarrassing ... Yes, to no one's surprise it's now working.

Thanks

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.