g++ unicode 变量名 [英] g++ unicode variable name
问题描述
我正在尝试在 g++ 中使用 unicode 变量名.
I am trying to use unicode variable names in g++.
它似乎不起作用.
g++ 是否不支持 unicode 变量名,...或者是否存在 unicode 的某些子集(我没有在其中进行测试).
Does g++ not support unicode variable names, ... or is there some subset of unicode (from which I'm not testing in).
谢谢!
推荐答案
编译时必须指定-fextended-identifiers
标志,unicode也必须使用uXXXX或uXXXXXXXX(至少在 gcc 中它是 unicode)
You have to specify the -fextended-identifiers
flag when compiling, you also have to use uXXXX or uXXXXXXXX for unicode(atleast in gcc it's unicode)
g++ 中的标识符(变量/类名等)不能是 utf-8/utf-16 或任何编码,他们必须是:
Identifiers (variable/class names etc) in g++ can't be of utf-8/utf-16 or whatever encoding, they have to be:
identifier:
nondigit
identifier nondigit
identifier digit
一个非数字是
nondigit: one of
universalcharactername
_ a b c d e f g h i j k l m n o p q r s t u v w x y z
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
一个通用字符名是
universalcharactername:
UXXXXXXXX
uXXXX
因此,如果您将源文件保存为 UTF-8,则不能有像例如这样的变量:
Thus, if you save your source file as UTF-8, you cannot have a variable like e.g.:
int høyde = 10;
它必须写成:
int hu00F8yde = 10;
(imo 会达到目的 - 所以坚持使用 a-z)
(which imo would beat the whole purpose - so just stick with a-z)
这篇关于g++ unicode 变量名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!