Clang now (>3.3) supports Unicode characters in variable names: Clang 3.3 Release Notes, Major New Features.
However, some special character are still forbidden.
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 ∞
(infinity) 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, and please take it as a technical question. 3) I am interested in C++ compiler of Clang 3.4 in Linux (GCC 4.8.3 (2014-05-22) 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: _∞
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 an error //double ⧞ = 99999.; // Infinity negated. Still an error double ꝏ = 99999.; // Letter oo double Ꝏ = 99999.; // Letter OO //double ⧜ = 99999.; // Incomplete infinity. Still an error
Other "alternative" dead ringers mentioned in the question that are in the allowed range:
ʃ
,.
Note: This question has Unicode text that may not display correctly in all browsers.