MISRA C:2023 Rule 8.3
R2026bAll declarations of an object or function shall use the same names and type qualifiers
自 R2024a 起
描述
All declarations of an object or function shall use the same names and type qualifiers 1 .
理由
在同一对象或函数的所有声明中使用一致的参数名称和参数类型有助于增强类型检查。这样,可以更轻松地检查是否所有声明中都使用了相同的函数接口。
例外情况:
使用相同基本类型的兼容版本并不违反此规则。例如,您可以互换使用
signed、int和signed int。使用未命名的函数参数并不违反此规则。例如,互换使用
void foo(int a)声明和void foo(int)声明。
Polyspace 实现
规则检查项会检测多个声明之间或声明与定义之间的参数名称或数据类型存在差异的情况。检查项会检查所有翻译单元中的声明,并标记出编译器不太可能检测到的问题。
故障排除
如果您预期会出现违规,但未看到该违规,请参阅诊断为何编码规范违规未按预期显示。
示例
检查信息
| 组:声明和定义 |
| 类别:必需 |
| AGC 类别:必需 |
PQL 名称:std.misra_c_2023.R8_3 |
版本历史记录
在 R2024a 中推出另请参阅
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:2025
MISRA C++:2008
MISRA C++:2023
MISRA and MISRA C are registered trademarks of The MISRA Consortium Limited 2021.