Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Underlying type of unary minus operator (-var)
#2
The underlying type is uint8_t, which will be converted by the integer promotions to the type int. You can never assume that int is either signed or unsigned. As I see it, you must therefore always typecast to conform with MISRA:

mc2_1209_u8a = (uint8_t) -mc2_1209_u8a;

However, I believe that the following should also be compliant:

mc2_1209_u8a -= mc2_1209_u8a;
<t></t>


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)