我正在用 C++ 制作一个枚举,以使用二进制标志制作一个有限状态机。看起来像:
enum VStates
{
NEUTRAL = 0x00000000, // 000000
// Physical Status
DRY = 0x00000001, // 000001
WET = 0x00000002, // 000010
HOT = 0x00000004, // 000100
COLD = 0x00000008, // 001000
BURNED = 0x00000016, // etc..
FROZEN = 0x00000032,
EROS = 0x00000064, //
THANATOS = 0x00000128, //
SLEEP = 0x00000256,
STUNNED = 0x00000512,
PARALYZED = 0x00001024,
POISONED = 0x00002048, //
BLIND = 0x00004096,
SOFT = 0x00008192, // Flexible
TOUGH = 0x00016384, // Resistent
MAGNETIZED = 0x00032768,
POSSEDERUNT = 0x00131072, //
// Mental Status
ANGRY = 0x00262144,
DRUGGED = 0x00524288, // Drugs Meaning
HORNY = 0x01048576, // Sexual Meaning
// Material Status
METAL = 0x02097152,
WOOD = 0x04194304,
GLASS = 0x08388608,
AIR = 0x16777216,
EARTH = 0x33554432,
DUST = 0x67108864,
LIGHT = 0x134217728,
SHADOW = 0x268435456,
WATER = 0x536870912,
// Total Status
PROTECTED = 0x1073741824,
INVULNERABLE = 0x2147483648
};
有些状态是不兼容的,所以我使用按位运算符来管理它们。现在,我的编译器说:
warning: integer constant is too large for 'long' type
这是声明此枚举的正确方法吗?我喜欢避免警告,我该如何解决这个问题?