考虑一下这个无害的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)
为什么要为三字符分析字符串文字呢?
其他编译器也这样做吗?