MISRA C:2012 Rule 5.1
External identifiers shall be distinct
描述
默认 Polyspace® as You Code 分析中反激活了此检查项。请参阅Checkers Deactivated in Polyspace as You Code Analysis (Polyspace Access)。
规则定义
External identifiers shall be distinct 1 .
理由
外部标识符是用全局作用域或存储类 extern
声明的标识符。
如果两个长名称几乎完全相同,差异仅出现在靠后的部分,则这两个名称很有可能被混用。这降低了代码的可读性。
Polyspace 实现
如果两个名称的前 31 个字符之间存在差异,则 Polyspace 会将它们视为不同的名称。对于 C90,前 6 个字符之间必须存在差异。要使用 C90 规则检查,请为 C 标准版本 (-c-version)
选项使用 c90
值。您可以使用 -code-behavior-specifications
选项更改比较的字符数。请参阅 -code-behavior-specifications
。
报告中的补充消息
文件 YY 中的外部 %s %s
与外部标识符 XX 冲突。
故障排除
如果您预计存在违规,但未看到该违规,请参阅Diagnose Why Coding Standard Violations Do Not Appear as Expected。
示例
检查信息
组:标识符 |
类别:必需 |
AGC 类别:必需 |
版本历史记录
在 R2014b 中推出
另请参阅
MISRA C:2012 Rule 5.2
| MISRA C:2012 Rule 5.4
| MISRA C:2012 Rule 5.5
| 检查 MISRA C:2012 (-misra3)
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.