c++enumsg++enum-class

enum class in c++ can not compile in Mac, while works in Windows


it seems there are some problems with my g++ 4.2 compiler in my Mac. I defined a enum class as follows.

enum class Suit {CLUBS,SPADES,HEARTS,DIAMONDS};

It can compile and run in VS2013 but failed to compile in my Mac (expected identifier or '{'). Is that the problem of my g++? How to upgrade it?


Solution

  • enum class will compile if your compiler supports C++11 Strongly-typed enums.
    It is available starting GCC 4.4
    http://gcc.gnu.org/projects/cxx0x.html