I π to find that I cannot use π as a valid identifier with g ++ 4.7, even with the -fextended-identifiers option -fextended-identifiers :
int main(int argc, const char* argv[]) { const char* π = "I'm very happy"; return 0; }
main.cpp: 3: 3: error: roaming '\ 360 in the program
main.cpp: 3: 3: error: wandering '\ 237 in the program
main.cpp: 3: 3: error: deviation '\ 230 in the program
main.cpp: 3: 3: error: wandering '\ 203 in the program
After some googling, I found that UTF-8 characters are not yet supported in identifiers , but a universal symbol-name should work. Therefore, I convert my source to:
int main(int argc, const char* argv[]) { const char* \U0001F603 = "I'm very happy"; return 0; }
main.cpp: 3: 15: error: universal character \ U0001F603 is not valid in identifier
Thus, it is obvious that π is not a valid identifier character. However, the standard specifically allows the use of characters from the range 10000-1FFFD in Appendix E.1 and does not prohibit it as the starting character in E.2. My next effort was to see if any other Unicode characters were working, but none of them tried. Even irrelevant PILE OF POO (π©) .
So, for the sake of meaningful and descriptive variable names, what gives? Does -fextended-identifiers , how does it advertise or not? Is this only supported in the latest build? And what kind of support do other compilers have?
c ++ gcc c ++ 11 unicode g ++
Joseph Mansfield Oct 02 2018-12-12T00: 00Z
source share