This question has unicode text that may not display correctly in all browsers.
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
}
giving:
error: non-ASCII characters are not allowed outside of literals and identifiers
double ∞ = 99999.;
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?
Is there a workaround or an option to allow this set of characters in clang
(or BTW in gcc
)?
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: _∞
See Question&Answers more detail:osThe 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
Other "alternative" dead ringers mentioned in the question that are in the allowed range:
?
,????????
.