warning: right shift count >= width of type

来源:互联网 发布:js搅拌机型号 编辑:程序博客网 时间:2024/05/01 05:59

      linux上编译mkyaffs2image工具, 出现如下警告:

src/main.c:18: warning: right shift count >= width of type。

     代码如下:

int  func(void){

    int file_size_low, file_size_high;


   ...

    stat("./inittab", &s);
    file_size_low = s.st_size;
    file_size_high = s.st_size>>32;  //引起警告的语句

   ...

}

   s.st_size向右移32位,为引起警告?s.st_size是long int类型,在32位的linux系统是32位,而不是64位。右移位数为32%32= 0, 所以file_size_hight = file_size_low = s.st_size。

   在arm中long类型是至少32位, long long int是64位

  

   

   

 


0 0