Problem with 'enum class'

I had one enumeration that worked, which is the one below:

enum RunMode  {
    Wait,
    AutoSend,
    Stopped,
    Requested
};

..and at some point of the program I write:

RunMode mode =Wait;

This works, OK. But the problem is that I would prefer the C++ syntax:

enum class RunMode  {
    Wait,
    AutoSend,
    Stopped,
    Requested
};

so that I could write the much clearer:

mode=RunMode::Wait;

This would allow to use the identifier 'Wait' for other enumerations too. The compiler will NOT let me compile this (it says 'expected identifier before 'class'), which seems a little awkward to me! Is there an issue with the compiler?

But the problem is that I would prefer the C++ syntax:

Where did you get the idea that that was the C++ syntax?

class is a keyword. It can not be used in conjunction with enum except in C++11, which the Arduino doesn't use (yet).

I saw it from here (Other data types - C++ Tutorials)…
I saw that C++ was supported because of the Serial class (among other classes).
Do you know how can I see the version of the C++ that the compiler supports??

+1, would like support for class enum in arduino.

PaulELong: +1, would like support for class enum in arduino.

Necro'ing a 6 year old thread probably won't provide sufficient impetus. :)

If you declare 'mode' you can assign it a value with "mode = RunMode::Wait;". Are you saying that with 'enum class' you don't have to declare a variable before assigning it a value?!?

 enum RunMode  { Wait, AutoSend, Stopped, Requested};


RunMode mode;


void setup() {
  mode = RunMode::Wait;
  auto mode2 = RunMode::Wait;  // Can also be:  auto mode2 = Wait;


  switch (mode2)
  {
     // "enumeration value 'xxx' not handled"  warnings here show that 'mode2' is declared as RunMode.
  }
}


void loop() {}

johnwasser: ``` enum RunMode  { Wait, AutoSend, Stopped, Requested};

RunMode mode;

void setup() {  mode = RunMode::Wait;  auto mode2 = RunMode::Wait;  // Can also be:  auto mode2 = Wait;

 switch (mode2)  {     // "enumeration value 'xxx' not handled"  warnings here show that 'mode2' is declared as RunMode.  } }

void loop() {}

This does not compile with Arduino 1.8.13 at least.

In function 'void setup()': parking_brake_1:8:10: error: 'RunMode' is not a class or namespace mode = RunMode::Wait; ^

Similarly, attempts at using enum class in this way also fail. C++11 mode is apparently enabled in platform.txt. Am I missing something?

slowriot: This does not compile with Arduino 1.8.13 at least.

Your sample compiles fine for me with 1.8.12.