主要内容

本页翻译不是最新的。点击此处可查看最新英文版本。

MISRA C:2012 Rule 4.2

Trigraphs should not be used

描述

规则定义

Trigraphs should not be used 1 .

理由

可以用两个问号后跟一个特定的第三个字符来表示三字符序列(例如,'??-' 表示一个 '~'(波浪号)字符,'??)' 表示一个 ']' 字符)。这些三字符序列可能会与两个问号的其他用法意外混淆。

注意

双字符序列(<: :><% %>%:%:%:)是允许使用的,因为它们是标记。

Polyspace 实现

Polyspace® 分析会将三字符序列转换为等效字符,以用于缺陷分析。然而,Polyspace 也会引发 MISRA™ 违规。

标准要求在预处理期间,必须在删除注释之前转换三字符序列。因此,即使三字符序列出现在代码注释中,Polyspace 也会报告违反此规则。

故障排除

如果您预计存在违规,但未看到该违规,请参阅Diagnose Why Coding Standard Violations Do Not Appear as Expected

检查信息

组:字符集和词法约定
类别:建议
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.