I came across an enum definition :-
typedef enum NSInteger {
kBorderTypeNone = 0,
kBorderTypeLeft = 1 << 0,
kBorderTypeRight = 1 << 1,
kBorderTypeTop = 1 << 2,
kBorderTypeBottom = 1 << 3
} BorderType;
and also (possibly) it can be equivalent to
typedef enum NSInteger {
kBorderTypeNone = 0,
kBorderTypeLeft = 1 ,
kBorderTypeRight = 2,
kBorderTypeTop = 4,
kBorderTypeBottom = 8
} BorderType;
What are the internal differences(if any)? Is there any advantage of one over the other? Which one is recommended?
Edit 1: If both are same then how compiler handles it? In which phase of compiler is it reduced to same set of instructions?
Both the formats compiles to same. First one is efficient from easy programming point of view. Second one is more efficient during compilation time as it is direct assignment of value.