Search code examples
cqa-c

How to avoid "Bitwise operations on signed data will give implementation defined results" in QAC?


I am getting

Msg(3:4130) Bitwise operations on signed data will give implementation defined results

this warning in QAC. The code like

functionName( a | b | c);

QAC on PIC micro controller code. Anyone can explain. what is this warning and how to avoid this warning.


Solution

  • In your code functionName( a | b | c);

    You are calling this function functionName with a | b | c where as a argument where | performs the bitwise operations. Performing bitwise operations (|) on signed integers (a,b,c) will return the implementation defined results.

    You can avoid this warning by typecasting the variables a,b,c as below

    functionName( (unsigned)a | (unsigned)b | (unsigned)c)
    

    The above code will change the type of a,b,c so that the QAC warning can be avoided