MISRA C:2023 Rule 5.2
描述
规则定义
Identifiers declared in the same scope and name space shall be distinct 1 .
理由
如果两个长名称几乎完全相同,差异仅出现在靠后的部分,则这两个名称很有可能被混用。这降低了代码的可读性。
Polyspace 实现
如果两个名称的前 63 个字符之间存在差异,则 Polyspace® 会将它们视为不同的名称。在 C90 中,前 31 个字符之间必须存在差异。要使用 C90 规则检查,请为 C 标准版本 (-c-version) 选项使用 c90 值。您可以使用 -code-behavior-specifications 选项更改比较的字符数。请参阅 -code-behavior-specifications。
故障排除
如果您预期会出现违规,但未看到该违规,请参阅诊断为何编码规范违规未按预期显示。
示例
检查信息
| 组:标识符 |
| 类别:必需 |
| AGC 类别:必需 |
版本历史记录
在 R2024a 中推出
另请参阅
检查 MISRA C:2023 (-misra-c-2023) | MISRA C:2023 Rule 5.1 | MISRA C:2023 Rule 5.3 | MISRA C:2023 Rule 5.4 | MISRA C:2023 Rule 5.5
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.