3
2

More than 5 years have passed since last update.

文字列リテラル中に意図せずトライグラフが登場した場合の対処

Last updated at Posted at 2017-01-08

Cプログラム中で文字列リテラル"????-??-??"を使いたくなったが、これを普通にコンパイルするとトライグラフと解釈されてしまう(なんと「??-」が一文字の扱いなのだ)。gcc限定のコードであればデフォルトでトライグラフ無効になっているので問題にはならないが、ポータビリティを考えるとあまり良くない。

解決策はWikipediaの「Digraphs and trigraphs」にも書いてある通り、次の2通りしかない。

"???\?-?\?-??"
"????""-??""-??"

読みやすい方でどうぞ。

参考URL

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2