zoukankan      html  css  js  c++  java
  • shift count is too large

    STM8S是8 bit单片机
    在STM8S中 unsigned long是32位, unsigned short和unsigned int都是16位,unsigned char是8位。

    以以下代码编译时报了“shift count is too large”的warning, 并且代码执行时也没有达到预期效果:

    1 unsigned char temp[4];
    2 unsigned long pd_reg;
    3 ...
    4 pd_reg = temp[3] << 24 | temp[2] << 16 | temp[1] << 8 | temp[0];

    后面加上了强制类型转换解决了此问题:

    1 unsigned char temp[4];
    2 unsigned long pd_reg;
    3 ...
    4 pd_reg = (unsigned long)temp[3] << 24 | (unsigned long)temp[2] << 16 | (unsigned long)temp[1] << 8 | (unsigned long)temp[0];
  • 相关阅读:
    1
    webpack
    webpack32
    41324
    124
    CSS 32
    Git 分支管理
    Git 标签管理
    datetime的timedelta对象
    unittest中的testCase执行顺序
  • 原文地址:https://www.cnblogs.com/wanglouxiaozi/p/12420745.html
Copyright © 2011-2022 走看看