Cocoa uses typedef-ed anum enum bit fields.
I use objective-C ++, for better and worse. Inside the .mm file, I need to assign 2 bits (a bitwise inclusion of OR) for a property of the type of one of these types of enumeration bit fields. The libC ++ compiler will not have it, because it will not give an rvalue of type int for the property of the specified bit field of the anonymous enumeration typedef-ed.
I understand that there is a difference in the size of the enumerations between C and C ++. So what is the situation for this situation?
My assignment line is akin to:
uiSwipeRightDownRecogniser.direction = Right | Down;
The definition of a bit field is akin to:
typedef enum { Right = 1 << 0, Left = 1 << 1, Up = 1 << 2, Down = 1 << 3 } UISwipeDirection;
Error:
Cannot initialize parameter of type 'UISwipeDirection' with rvalue of type 'int'
This assignment works in the .m file, but not the .mm file.
The compiler is Apple LLVM 3.0 (using libC ++).
source share