objective c - enum acting like an unsigned int in Xcode 4.6 even when enum is defined as a signed int -
i have been able recreate bug using xcode 4.6. works expected using xcode 4.5
the issue myval has right bit construction represent int val of -1. however, showing value of 4294967295 value of same bit construction if represented unsigned int. you'll notice if cast myval int show right value. strange, because enum should int beingness with.
here screen shot showing value of of variables in debugger @ end of 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 line of code myval 0 btenumvalue myval = btenumvaluezero; //we adding -1 value of 0 myval += btenumvaluenegone; //at moment myval has exact bit stucture //of signed int @ -1, displaying //as unsigned int, value 4294967295 //however, if cast enum (which should //be int signing) int, displays //the right value of -1 int myintval = (int)myval; } homecoming 0; }
the new, preferred way declare enum
types ns_enum
macro explained in post: http://nshipster.com/ns_enum-ns_options/
objective-c xcode
No comments:
Post a Comment