Sun Studio 12:C 用户指南

B.2.149 -xtrigraphs

-xtrigraphs 选项确定编译器是否识别 ISO C 标准定义的三字符序列。

缺省情况下,编译器假定 -xtrigraphs=yes 并识别整个编译单元的所有三字符序列。

如果源代码具有包含问号 (?) 的文字串(编译器将其解释为三字符序列),那么您可以使用 -xtrigraph=no 子选项关闭对三字符序列的识别。-xtrigraphs=no 选项可关闭整个编译单元内的所有三字母识别。

请考虑以下名为 trigraphs_demo.c 的源文件示例。


#include <stdio.h>

int main ()
{

  (void) printf("(\?\?) in a string appears as (??)\n");

  return 0;
}

下面是使用 -xtrigraphs=yes 编译该代码后的输出。


example% cc -xtrigraphs=yes trigraphs_demo.c
example% a.out
(??) in a string appears as (]

下面是使用 -xtrigraphs=no 编译该代码后的输出。


example% cc -xtrigraphs=no trigraphs_demo.c
example% a.out
(??) in a string appears as (??)