I'm very new to dealing with bits and have got stuck on the following warning when compiling:
7: warning: left shift count >= width of type
My line 7 looks like this
unsigned long int x = 1 << 32;
This would make sense if the size of long
on my system was 32 bits. However, sizeof(long)
returns 8
and CHAR_BIT
is defined as 8
suggesting that long should be 8x8 = 64 bits long.
What am I missing here? Are sizeof
and CHAR_BIT
inaccurate or have I misunderstood something fundamental?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…