Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Left Shifts and Castings
#1
Is the following acceptable under 10.5?
[code]
unsigned char u = 1u;
(unsigned char) u
#2
Yes that is correct. The result must be typecasted in order to conform with rule 10.5.

The typecast to unsigned char in the first example will not have any effect at all. The typecast operator has higher priority than
<t></t>
#3
[code]
uint8_t u =1;
uint8_t v;
uint8_t w;

v = u
Posted by and on behalf of the MISRA C Working Group


Forum Jump:


Users browsing this thread: 1 Guest(s)