小编Rob*_*ove的帖子

为什么在Gnu gcc/g ++中为三字符序列解析字符串文字?

考虑一下这个无害的C++程序:

#include <iostream>
int main() {
  std::cout << "(Is this a trigraph??)" << std::endl;
  return 0;
}
Run Code Online (Sandbox Code Playgroud)

当我使用g ++版本5.4.0编译它时,我得到以下诊断:

me@my-laptop:~/code/C++$ g++ -c test_trigraph.cpp
test_trigraph.cpp:4:36: warning: trigraph ??) ignored, use -trigraphs to enable [-Wtrigraphs]
   std::cout << "(Is this a trigraph??)" << std::endl;
                                     ^
Run Code Online (Sandbox Code Playgroud)

程序运行,其输出符合预期:

(Is this a trigraph??)
Run Code Online (Sandbox Code Playgroud)

为什么要为三字符分析字符串文字呢?

其他编译器也这样做吗?

c++ gcc trigraphs

1
推荐指数
1
解决办法
177
查看次数

标签 统计

c++ ×1

gcc ×1

trigraphs ×1