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?

有帮助吗?

解决方案

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

其他提示

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?

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top