1

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?

Barmar
  • 741,623
  • 53
  • 500
  • 612
ivory
  • 243
  • 4
  • 16

3 Answers3

2

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

lolando
  • 1,721
  • 1
  • 18
  • 22
0

http://gcc.gnu.org/projects/cxx0x.html covers the c++11 language features and when they were supported. GCC 4.4 added the strongly typed enum support. I thought apple switched Xcode over to clang a while ago, or at least included it as an option?

Charlie
  • 1,487
  • 10
  • 9
0

You should use clang for apple. gcc 4.2 does not support them I guess. If you want to use a more recent gcc in apple environment, take a look at this question with its answer.

Community
  • 1
  • 1
Germán Diago
  • 7,473
  • 1
  • 36
  • 59