Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22250
тЖз

ЁЯШГ (and other unicode characters) in identifiers not allowed by g++

$
0
0

I am ЁЯШЮ to find that I cannot use ЁЯШГ as a valid identifier with g++ 4.7, even with the -fextended-identifiers option enabled:

int main(int argc, const char* argv[]){  const char* ЁЯШГ = "I'm very happy";  return 0;}

main.cpp:3:3: error: stray тАШ\360тАЩ in program
main.cpp:3:3: error: stray тАШ\237тАЩ in program
main.cpp:3:3: error: stray тАШ\230тАЩ in program
main.cpp:3:3: error: stray тАШ\203тАЩ in program

After some googling, I discovered that UTF-8 characters are not yet supported in identifiers but a universal-character-name should work. So 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 an identifier

So apparently ЁЯШГ isn't a valid identifier character. However, the standard specifically allows characters from the range 10000-1FFFD in Annex E.1 and doesn't disallow it as an initial character in E.2. My next effort was to see if any other allowed unicode characters worked - but none that I tried did. Not even the ever important PILE OF POO (ЁЯТй) character.

So, for the sake of meaningful and descriptive variable names, what gives? Does -fextended-identifiers do as it advertises or not? Is it only supported in the very latest build? And what kind of support do other compilers have?

тЖз

Viewing all articles
Browse latest Browse all 22250

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>