What does '<<' mean in C?

前端 未结 5 1881
一生所求
一生所求 2021-01-07 08:33

what does this mean?

#define WS_RECURSIVE    (1 << 0)

I understand that it will define WS_Recursive (1 << 0) but w

5条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-07 09:12

    The << operator shifts the left-hand value left by the (right-hand value) bits. Your example does nothing! 1 shifted 0 bits to the left is still 1. However, 1 << 1 is 2, 1 << 2 is 4, etc. Is WS_RECURSIVE a flag in a bitfield?

提交回复
热议问题