Oracle Solaris Studio 12.2: C ユーザーガイド

B.2.154 -xtrigraphs

-xtrigraphs オプションは、コンパイラが ISO 規格で定義されている三文字表記シーケンスを認識するかどうかを決定します。

デフォルトにより、コンパイラは -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 (??)