#include <stdio.h>
#include <stdint.h>
int main(){
uint64_t a = 1 << 63;
/* do some thing */
return 0;
}$ gcc -Wall -Wextra -std=c99 test.c -o test
warning: left shift count >= width of type [-Wshift-count-overflow]问:uint64_t应该有64位宽,为什么左移位操作会溢出?
发布于 2017-03-28 03:58:48
1是一个int,可以是平台上的32位,也可以是64位,但需要签名。
首先使用(uint64_t)1 << 63将1转换为64位无符号整数.(如果您愿意,也可以使用((uint64_t)1) << 63 )
https://stackoverflow.com/questions/43060408
复制相似问题