PC-Lint 9.00L 版本查看以下代码:
typedef unsigned char boolean_t; //This is actually in a system header file.
...
/* The rest is in the .c file I'm working on. */
boolean_t booleanVal
...
uint8_t maskedVal;
maskedVal = 0; //real code has this assigned based on a bitwise-and
booleanVal = ( maskedVal != 0U );
并给出此错误:
booleanVal = ( maskedVal != 0U );
^
"LINT: <filename> Note 960: Violates MISRA 2004
Required Rule 10.1, Implicit conversion of integer to smaller type"
-strong(B, boolean_t )
我已在我的 .lnt 文件中将boolean_t 声明为强布尔类型。
那么,当我将一个明确的布尔表达式分配给一个明确的布尔变量时,为什么 PC-Lint 会抱怨转换整数呢?