MISRA C:2012 Rule 5.5
Identifiers shall be distinct from macro names
描述
规则定义
Identifiers shall be distinct from macro names 1 .
理由
该规则要求,仅在处理之前存在的宏名称必须与预处理后也存在的标识符名称不同。保持宏名称和标识符的唯一性有助于避免混淆。
Polyspace 实现
如果两个名称的前 63 个字符之间存在差异,则 Polyspace® 会将它们视为不同的名称。在 C90 中,差异必须出现在前 31 个字符之间。要使用 C90 规则检查,请为 C 标准版本 (-c-version)
选项使用 c90
值。您可以使用 -code-behavior-specifications
选项更改比较的字符数。请参阅 -code-behavior-specifications
。
报告中的补充消息
标识符 XX 与宏 YY 具有相同的有效字符。
故障排除
如果您预期会出现违规,但未看到该违规,请参阅诊断为何编码规范违规未按预期显示。
示例
检查信息
组:标识符 |
类别:必需 |
AGC 类别:必需 |
版本历史记录
在 R2014b 中推出
另请参阅
MISRA C:2012 Rule 5.1
| MISRA C:2012 Rule 5.2
| MISRA C:2012 Rule 5.4
| 检查 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.