Eclipse 中的枚举声明
我正在 Linux 的 Eclipse 中编译一个 C++ 项目。
该项目过去是在Windows 中编译的。
我有这样的枚举声明:
enum nameofenum:UINT32
{
one=0,
two=1
}
结果是 Eclipse 中的错误。
:UINT32
是什么意思?- 如何将此声明切换到 Linux?
谢谢!!
I'm compiling a c++ project in Eclipse, Linux.
The project was compiled in Windows in the past.
I have my declaration of enums like this:
enum nameofenum:UINT32
{
one=0,
two=1
}
The result is an error in eclipse.
- What is the meaning of
:UINT32
? - How can I switch this declaration to Linux?
Thanks!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这看起来像一个强类型枚举,它是一个C++0x特征。基本上,它指定枚举的基础类型,因此
one
和two
将是UINT32
。要编译它,您需要一个支持 C++0x 语言的这个特定部分的编译器。我相信 GCC 4.4 和 Visual C++ 在某种程度上支持强类型枚举。
That looks like a strongly typed enum, which is a C++0x feature. Basically, it specifies the underlying type of the enumeration, so
one
andtwo
will beUINT32
s.To compile it, you need a compiler that supports this particular part of the C++0x language. I believe GCC 4.4 and Visual C++ supports strongly typed enums to some extent.
: UINT32
声明枚举的基础类型;这意味着枚举将由UINT32
表示。这是 C++0x 中添加的一项新 C++ 功能,称为强类型枚举。 Visual C++ 至少从 Visual C++ 2005 开始就支持它;您使用的 g++ 版本可能不支持它。
至于如何使用 g++ 来实现这一点,这取决于情况。如果您没有任何依赖于特定基础类型的代码,那么您可以将其删除。如果您确实有依赖于特定基础类型的代码,则可以考虑将枚举类型的使用替换为基础类型(即使用
UINT32
而不是nameofenum
);但这不太好。The
: UINT32
declares the underlying type of the enumeration; it means that the enumeration will be represented by aUINT32
.This is a new C++ feature that is being added in C++0x called strongly typed enumerations. Visual C++ has supported it at least since Visual C++ 2005; the version of g++ you are using may not support it.
As for how you get this working with g++, it depends. If you don't have any code that relies on a particular underlying type, then you can just remove it. If you do have code that relies on a particular underlying type, you might consider replacing uses of the enumeration type with the underlying type (i.e., use
UINT32
instead ofnameofenum
); this isn't very nice, though.: UINT
表示枚举标识符的基础类型是UINT
。它是此处描述的 Microsoft 扩展。要使其编译,请删除
: UINT
。: UINT
means that the underlying type of the enumeration identifiers isUINT
.It is a Microsoft extension described here. To make it compile remove
: UINT
.