17

My compiler (gcc) is giving me this warning. Please help me to understand what it means:

warning: trigraph ??/ ignored, use -trigraphs to enable

Jon
  • 428,835
  • 81
  • 738
  • 806
Angus
  • 12,133
  • 29
  • 96
  • 151
  • `??/` is the equivalent of backslash, you can replace the triagraph to "\" – Eric Fortis Dec 08 '11 at 17:58
  • 1
    Unless you're (say) editing C code on a mainframe 3270 terminal, or so forth, it's a "good idea" to write an occurrence of "??" as "?\?", for paranoia's sake. (Some characters, like {} [] \, are absent in many mainframe character sets, as well as some non-English keyboards for other systems.) – BRPocock Dec 08 '11 at 18:06
  • 3
    The dusty corners of C strike again... – tdenniston Dec 08 '11 at 18:07

2 Answers2

18

You have "accidentally" written a trigraph somewhere in your source code (the compiler's warning would pinpoint the line). Since trigraphs were invented to solve a problem that doesn't come into play on modern systems, you don't actually want the trigraph ??/ to be replaced with the character \.

Therefore, this warning should probably be ignored (you can tell the compiler to shut up by adding -Wno-trigraphs after -Wall in your command line; see the docs). But it would be good to show your source code so we can be sure.

Community
  • 1
  • 1
Jon
  • 428,835
  • 81
  • 738
  • 806
16

Instead of adding a compiler flag, you could just escape each question mark with \, i.e. \?\?-. This helped in my case.

Lukasz Czerwinski
  • 13,499
  • 10
  • 55
  • 65
  • 2
    Compiler flag is supposed for cases where you write a trigraph without noticing it is one. Then compiler will not annoy you about it. If you knew at the time of writing that it is an unintended trigraph, then you could escape it as you suggested and forget compiler flags. – j_kubik Mar 20 '14 at 07:56