g ++ unicode变量名称 [英] g++ unicode variable name
问题描述
我试图在g ++中使用unicode变量名。
它看起来不起作用。
g ++是否不支持unicode变量名称,或者是否存在unicode的一些子集(从中我没有测试)。
谢谢!
在编译时,您必须指定 -fextended-identifiers
标志,必须使用\uXXXX或\×××××××××作为unicode(至少在gcc中它是unicode)
$ b $ -8 / utf-16或其他编码,
必须是:
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
标识符nondigit
标识符数字
非数字是
nondigit:
之一universalcharactername
_ abcdefghijklmnopqrstu vwxyz
ABCDEFGHIJKLMNOPQRSTU VWXYZ
以及universalcharactername是
universalcharactername:
\UXXXXXXXX
\uXXXX
因此,如果将源文件保存为UTF-8,则不能有如下所示的变量:
inthøyde= 10;
它必须写成:
int h\\\øyde = 10;
(其中imo会胜过整个目的 - 所以只需使用az)
I am trying to use unicode variable names in g++.
It does not appear to work.
Does g++ not support unicode variable names, ... or is there some subset of unicode (from which I'm not testing in).
Thanks!
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)
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
a nondigit is
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
and a universalcharactername is
universalcharactername:
\UXXXXXXXX
\uXXXX
Thus, if you save your source file as UTF-8, you cannot have a variable like e.g.:
int høyde = 10;
it had to be written like:
int h\u00F8yde = 10;
(which imo would beat the whole purpose - so just stick with a-z)
这篇关于g ++ unicode变量名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!