关于C/C++的trigraphs和Digraphs

仔细看了看wiki

当初因为iso646的标准,部分国家打不出# ~ ^ 之类的字符,所以使用??加一个字符替代。

TrigraphEquivalent
??= #
??/ \
??' ^
??( [
??) ]
??! |
??< {
??> }
??- ~

后来在c99加入了digraphs

DigraphEquivalent
<: [
:> ]
<% {
%> }
%: #

然后目前,gcc编译trigraphs 要使用-trigraphs 且未使用会警告。

如果-ansi 会默认加上-trigraphs。

c++或者c中的iso646.h还支持这个

TokenEquivalent
%:%: ##
compl ~
not !
bitand &
bitor |
and &&
or ||
xor ^
and_eq &=
or_eq |=
xor_eq ^=
not_eq !=

所以当初lez大佬发现的那个东西是有名字的。。。

 

在c++11,trigraphs被建议不使用,c++17中,被弃用了。

 

参考:https://en.wikipedia.org/wiki/Digraphs_and_trigraphs

posted @ 2017-10-25 11:41  木颍同  阅读(716)  评论(0编辑  收藏  举报