MISRA C:2012 Rule 8.8
The static storage class specifier shall be used in all declarations of objects and functions that have internal linkage
描述
规则定义
The static storage class specifier shall be used in all declarations of objects and functions that have internal linkage 1 .
理由
如果未在所有具有内部链接的对象声明中一致地使用 static 指定符,则可能会声明具有外部和内部链接的相同对象。
在此情况下,链接遵循之前可见的规范(C99 标准,第 6.2.2 节)。例如,如果先前的说明指明内部链接,则即使后面的说明指明外部链接,该对象也有内部链接。如果您只注意到后面的规格,您可能会得到不同的结果。
Polyspace 实现
此规则检查项检测下列情形:
使用不同的存储指定符多次声明了相同的对象。
使用不同的存储指定符声明和定义了相同的函数。
故障排除
如果您预期会出现违规,但未看到该违规,请参阅诊断为何编码规范违规未按预期显示。
示例
检查信息
| 组:声明和定义 |
| 类别:必需 |
| AGC 类别:必需 |
版本历史记录
在 R2014b 中推出
1 All MISRA coding rules and directives are © Copyright The MISRA Consortium Limited 2021.
The MISRA coding standards referenced in the Polyspace® Bug Finder™ documentation are from the following MISRA standards:
MISRA C:2004
MISRA C:2012
MISRA C:2023
MISRA C++:2008
MISRA C++:2023
MISRA and MISRA C are registered trademarks of The MISRA Consortium Limited 2021.