MISRA C:2012 Rule 8.3
All declarations of an object or function shall use the same names and type qualifiers
描述
规则定义
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 类别:必需 |
版本历史记录
在 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.