开发者

enum declaration in windows to linux

I have a C++ declaration:

enum SETTINGS:UINT32
{
     a=1,
     b=2,
};
  1. what is the meaning 开发者_StackOverflowof :UINT32?
  2. how can I swich this declaration to linux?


Its part of the new C++0x way of declaring enums

enum <EnumTypeName> [: <Optinal-Type>] { <ValueList> };

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


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.

  • See C++ Enumeration Declaration on MSDN for a description of this syntax
  • See this Wikipedia page regarding C++0x upcoming changes to enum declarations

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 = unsigned int = integer 32 = 32 bit

read this : "Uint32", "int16" and the like; are they standard c++?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜