Sun Studio 12: C User's Guide

B.2.149 -xtrigraphs

The -xtrigraphs option determines whether the compiler recognizes trigraph sequences as defined by the ISO C standard.

By default, the compiler assumes -xtrigraphs=yes and recognizes all trigraph sequences throughout the compilation unit.

If your source code has a literal string containing question marks (?) that the compiler is interpreting as a trigraph sequence, you can use the -xtrigraph=no suboption to turn off the recognition of trigraph sequences. The -xtrigraphs=no option turns off recognition of all trigraphs throughout the entire compilation unit.

Consider the following example source file named trigraphs_demo.c.


#include <stdio.h>

int main ()
{

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

  return 0;
}

Here is the output if you compile this code with -xtrigraphs=yes.


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

Here is the output if you compile this code with -xtrigraphs=no.


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