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?

4

3 回答 3

2

enum class如果您的编译器支持C++11 Strongly-typed enums.
它可以从GCC 4.4
http://gcc.gnu.org/projects/cxx0x.html开始

于 2013-10-31T04:53:00.223 回答
0

http://gcc.gnu.org/projects/cxx0x.html涵盖了 c++11 语言功能以及何时支持它们。GCC 4.4 添加了强类型枚举支持。我以为苹果不久前将 Xcode 切换为 clang,或者至少将其作为选项包含在内?

于 2013-10-31T05:04:03.273 回答
0

苹果应该使用 clang。我猜 gcc 4.2 不支持它们。如果您想在苹果环境中使用更新的 gcc,请查看这个问题及其答案

于 2013-10-31T06:58:41.637 回答