This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Strange Shift Warning

I am getting this warning:

warning C200: '>>': out of range shift factor has been truncated

with regards to this line of code:

Mbuf[1] = HEX2ASCII( (pEvent->num & 0xF000) >> 12 );

This warning does not appear when the identical project is compile on other machines!

Any ideas?

Rich

Parents Reply Children
  • The correlation is that that macro is written carelessly. To see what went wrong, inspect the preprocessor listing generated by the compiler on request, and ask yourself if that expanded expression really does what you wanted it to.

    The 'true' fix is to repair the macro definition, not the invocation:

    #define HEX2ASCII(b) (((b)>9) ? ((b)+'A'-10) : ((b)+'0'))
    And BTW, there almost certainly are more efficient ways of doing the job of this macro, including the very simple
    #define HEX2ASCII(b) digit_string[b]