MISRA C:2012 Rule 4.1
Octal and hexadecimal escape sequences shall be terminated
描述
规则定义
Octal and hexadecimal escape sequences shall be terminated 1 .
理由
如果八进制或十六进制转义序列后跟其他字符,可能会造成混淆。例如,字符常量 '\x1f'
由一个字符组成,而字符常量 '\x1g'
由两个字符 '\x1'
和 'g'
组成。多字符常量作为整数表示的方式由实现定义。
如果字符常量或字符串文字中的每个八进制或十六进制转义序列都结束,则可以减少潜在的混淆。
故障排除
如果您预期会出现违规,但未看到该违规,请参阅诊断为何编码规范违规未按预期显示。
示例
检查信息
组:字符集和词法约定 |
类别:必需 |
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.