Unicode /变量名中的特殊字符不允许在clang中使用? [英] Unicode/special characters in variable names in clang not allowed?

查看:317
本文介绍了Unicode /变量名中的特殊字符不允许在clang中使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


此问题的Unicode文字可能无法在所有浏览器中正确显示。

This question has unicode text that may not display correctly in all browsers.

clang now(> 3.3)支持变量名称中的Unicode字符 http://llvm.org/releases/3.3/tools/clang/docs/ReleaseNotes.html#major-new-features

clang now (>3.3) supports unicode characters in variable names http://llvm.org/releases/3.3/tools/clang/docs/ReleaseNotes.html#major-new-features.

但是一些特殊字符仍然是禁止的。

However some special character are still forbiden.

int main(){
    double α = 2.; // alpha, ok!
    double ∞ = 99999.; // infinity, error
}

给出:

error: non-ASCII characters are not allowed outside of literals and identifiers
        double ∞ = 99999.;

α clang 前者是unicode,而且(无限)后者不是unicode,但是同时不是ASCII?

What is the fundamental difference between α (alpha) and (infinty) for clang? That the former is unicode and the latter is not unicode but at the same time is not ASCII?

是否有解决方法或选项允许 clang (或在 gcc 中的BTW)?

Is there a workaround or an option to allow this set of characters in clang (or BTW in gcc)?

>注意:1)只是一个例子,有很多字符可能有用但也被禁止,例如。 2)我不是问是否是好主意,请把它作为一个技术问题。 3)我对Linux中的 clang 3.4 的C ++编译器感兴趣( gcc 4.8.3 不支持) 。我使用 UTF-8 编码和 Unix / Linux 保存源文件 gedit / code>行结束。 4)添加其他正常的第一个字符没有帮助:_∞

Notes: 1) is just an example, there are a lot of characters that are potentially useful but also forbidden, like or . 2) I am not asking if it is good idea, please take it as a technical question. 3) I am interested in C++ compiler of clang 3.4 in Linux (gcc 4.8.3 doesn't support this). I am saving the source files with gedit using UTF-8 encoding and Unix/Linux line ending. 4) adding other normal first characters doesn't help: _∞


答案指向一个确定的NO。一些范围的确不是
允许也不会很快。为了进一步移动到总
疯狂,最好的选择我发现是使用
字符有效地看起来相同。 (现在,这个我可能承认不是一个好主意。)这些替代品可以在这里找到
http://shapecatcher.com/ 。结果(对不起,如果它伤害你的眼睛):

The answers point to a definite NO. Some ranges are indeed not allowed nor will they be soon. To move one step further to total craziness, the best alternative I found was to use characters that effectively look the same. (Now, this I might admit is not a good idea.) Those alternatives can be found here http://shapecatcher.com/. The result (sorry if it hurts your eyes):

//    double ∞ = 99999.; // still error
//    double ⧞ = 99999.; // infinity negated still error
  double ꝏ = 99999.; // letter oo
  double Ꝏ = 99999.; // letter OO
//    double ⧜ = 99999.; // incomplete infinity still error

这篇关于Unicode /变量名中的特殊字符不允许在clang中使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆