我只能使用xCode 4.6重新创建此错误。一切都按预期使用Xcode 4.5
问题是myVal具有正确的位结构来表示-1的int值。但是,它显示的值为4294967295,如果由unsigned int表示,则为相同位结构的值。您会注意到,如果我将myVal转换为int,它将显示正确的值。这很奇怪,因为枚举应该是一个int。
这是一个屏幕截图,显示了main结束时调试器中所有变量的值。 http://cl.ly/image/190s0a1P1b1t
typedef enum : int {
BTEnumValueNegOne = -1,
BTEnumValueZero = 0,
BTEnumValueOne = 1,
}BTEnumValue;
int main(int argc, const char * argv[])
{
@autoreleasepool {
//on this line of code myVal is 0
BTEnumValue myVal = BTEnumValueZero;
//we are adding -1 to the value of zero
myVal += BTEnumValueNegOne;
//at this moment myVal has the exact bit stucture
//of a signed int at -1, but it is displaying it
//as a unsigned int, so its value is 4294967295
//however, if i cast the enum (which should already
//be an int with a signing) to an int, it displays
//the correct value of -1
int myIntVal = (int)myVal;
}
return 0;
}