Windows 到 Linux 中的枚举声明
我有一个 C++ 声明::
enum SETTINGS:UINT32
{
a=1,
b=2,
};
- UINT32 的含义是什么?
- 我怎样才能将此声明切换到linux?
I have a C++ declaration:
enum SETTINGS:UINT32
{
a=1,
b=2,
};
- what is the meaning of :UINT32?
- how can I swich this declaration to linux?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它是声明枚举的新 C++0x 方式的一部分默认
情况下,枚举由整数表示。
新语法允许您选择定义用于表示枚举的类型。
在这种情况下,它指示枚举底层表示形式应为 UINT32 类型。这意味着什么取决于宏 UINT32 的定义。但它可能是一个至少 32 位的整数并且是无符号的。 :-)
请参阅 Bjornes 对新枚举内容的描述:
http://www2.research.att.com/~bs/ C++0xFAQ.html#enum
Its part of the new C++0x way of declaring enums
By default an enum is represented by an integer.
The new syntax allows you to optionally define the type used to represent the enum
In this case it indicates that the enum underlying representation should be of type UINT32. What this means will depend on what the macro UINT32 has been defined to be. But it is probably an integer of at least 32 bits and is unsigned. :-)
See Bjornes description of the new enum stuff:
http://www2.research.att.com/~bs/C++0xFAQ.html#enum
这里,
:UINT32
语法指定底层枚举类型。但是,这不是标准 C++(至少不是标准 C++03),而是 Visual Studio 扩展:g++ 可能会拒绝它,您也应该这样做。编辑 正如 Martin York 的评论所指出的,g++ 从 4.4 版本开始支持这种语法,所以我猜 Linux portage 的唯一问题是
UINT32
是非标准的。Here, the
:UINT32
syntax specifies the underlying enum type. However, this is not standard C++ (at least, not standard C++03) but a Visual Studio extension : g++ will probably reject it, and you should too.EDIT As pointed in the comments by Martin York, g++ supports this syntax since version 4.4, so I guess the only issue for a Linux portage would be
UINT32
being non standard.u = 无符号
int = 整数
32 = 32 位
阅读:"Uint32", "int16"等等;它们是标准的 C++ 吗?
u = unsigned
int = integer
32 = 32 bit
read this : "Uint32", "int16" and the like; are they standard c++?