Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

c - How do I solve 10.4 MISRA 2012 rule?

Essential type of the left hand operand usart[0U].tx_count (unsigned) is not the same as that of the right operand "0" (signed).

if(usart[RS485_PORT].tx_count == 0) // error in this line
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

0 is a literal of type int which is a signed type, and tx_count is an unsigned field. Comparison between signed and unsigned are usually unexpected

To make the right hand side unsigned add the U suffix

if(usart[RS485_PORT].tx_count == 0U)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...