MISRA C Rule­6.1 0635 Rule­7.2 1281

时间:2024-10-12 20:52:47

、struct/union中的位域被声明为除int、signed int或unsigned int外的其他类型 ; 整型常量是无符号类型,但没有使用后缀符'U' 。

工具/原料

Rule­6.1 0635 Rule­7.2 1281

MISRA C:2012

Rule­6.1 0635

1、规则与等级对应关系(QAC)

MISRA C Rule­6.1 0635 Rule­7.2 1281

2、 罕铞泱殳 0635 [E] Bit-fields in this struct/u荏鱿胫协nion have been declared with types other than int, signed int or unsigned int.struct/union中的位域被声明为除int、signed int或unsigned int外的其他类型

3、根据ISO:C 标准,位域只能定义为以下类型:int/unsigned int/signed int。有些编译器髹瑕扔麝支持一些其他整型,比如char,short和enum。这属于语言的扩展,且是不可移植的。在struct或union声明中,无论含有多少非标准位域,消息0635只会生成一次。

MISRA C Rule­6.1 0635 Rule­7.2 1281

4、编程规范修改举例

MISRA C Rule­6.1 0635 Rule­7.2 1281

Rule­7.2 1281

1、规则与等级对应关系(QAC)

MISRA C Rule­6.1 0635 Rule­7.2 1281

2、 罕铞泱殳 1281 Integer literal constant is of 锾攒揉敫an unsigned type but does not include a "U" suffix. 这是整型常量是无符号类型,但没有使用后缀符 'U' 。注意:一个整数常量的类型,依赖于常量的值大小、'int'型被实现的大小(即是说 'int' 型是16位还是32位)以及出现的后缀符。

3、官方示例

MISRA C Rule­6.1 0635 Rule­7.2 1281

4、编程规范修改举例

MISRA C Rule­6.1 0635 Rule­7.2 1281
© 手抄报圈