MISRA C Rule­5.6 3448 Rule­6.1 0634

 时间:2026-02-12 12:16:13

typedef的声明不是在一个头文件中;

struct/union中的位域没有显式声明为unsigned或signed。

工具/原料

Rule­5.6 3448 Rule­6.1 0634

MISRA C:2012

Rule­5.6 3448

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

MISRA C Rule­5.6 3448 Rule­6.1 0634

3448 Declaration of typedef '%s' is not in a header file although it is used in a definition or declaration with external linkage. 

在多个地方定义一个typedef是没有意义的。如果这个typedef是用来声明/定义一个具有 外部链接 属性的对象/函数, 那么它应该被定义在一个头文件中。因为这可能意味着在多个 翻译单元中,都会使用到这个 '类型定义'。这样做比直接在每个源文件中都插入一个局部声明更安全、更容易维护。

官方示例

MISRA C Rule­5.6 3448 Rule­6.1 0634

编程规范修改举例

MISRA C Rule­5.6 3448 Rule­6.1 0634

Rule­6.1 0634

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

MISRA C Rule­5.6 3448 Rule­6.1 0634

0634 [I] Bit-fields in this struct/union have not been declared explicitly as unsigned or signed.

没有显式指定位域的符号类型。

ISO:C 标准中声明位域的类型可以是以下类型的任何一种:

int/unsigned int/signed int。

通常情况下,把int作为signed类型实现。但是,使用int定义一个位域时,实现时可能是signed类型或unsigned类型。具体由实现定义。 为排除这种不确定性,最好在实际情况中把位域的符号类型显式指定为unsigned int祸signed int类型。

实际情况中,编译器也支持其他整型(例如signed char, unsigned char)。struct或union声明的位域为char, short, int, long或long long类型时,生成消息0634。 在struct或union的声明中此消息只会出现一次。

MISRA C Rule­5.6 3448 Rule­6.1 0634

编程规范修改举例

MISRA C Rule­5.6 3448 Rule­6.1 0634

  • KM影视大全怎么清理视频缓存
  • 三生三世手游攻略
  • rule34使用方法
  • rule34怎样进入
  • 希露薇如何触发吸奶器?
  • 热门搜索
    的近义词 电池充不进电怎么办 圆寸发型 极路由怎么设置 狗狗疫苗怎么打 倩女幽魂怎么赚钱 河南省博物馆 活跃的近义词 侵蚀的近义词 爱上已婚男人怎么办