Note that there are some explanatory texts on larger screens.

plurals
  1. PO (and other unicode characters) in identifiers not allowed by g++
    primarykey
    data
    text
    <p>I am <a href="http://www.fileformat.info/info/unicode/char/1f61e/index.htm" rel="noreferrer"></a> to find that I cannot use <a href="http://www.fileformat.info/info/unicode/char/1f603/index.htm" rel="noreferrer"></a> as a valid identifier with g++ 4.7, even with the <code>-fextended-identifiers</code> option enabled:</p> <pre><code>int main(int argc, const char* argv[]) { const char* = "I'm very happy"; return 0; } </code></pre> <blockquote> <p>main.cpp:3:3: error: stray ‘\360’ in program<br> main.cpp:3:3: error: stray ‘\237’ in program<br> main.cpp:3:3: error: stray ‘\230’ in program<br> main.cpp:3:3: error: stray ‘\203’ in program </p> </blockquote> <p>After some googling, I discovered that <a href="http://gcc.gnu.org/wiki/FAQ#What_is_the_status_of_adding_the_UTF-8_support_for_identifier_names_in_GCC.3F" rel="noreferrer">UTF-8 characters are not yet supported in identifiers</a> but a <em>universal-character-name</em> should work. So I convert my source to:</p> <pre><code>int main(int argc, const char* argv[]) { const char* \U0001F603 = "I'm very happy"; return 0; } </code></pre> <blockquote> <p>main.cpp:3:15: error: universal character \U0001F603 is not valid in an identifier</p> </blockquote> <p>So apparently isn't a valid identifier character. However, the standard specifically allows characters from the range <code>10000-1FFFD</code> 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 <a href="http://www.fileformat.info/info/unicode/char/1f4a9/index.htm" rel="noreferrer">PILE OF POO ()</a> character.</p> <p>So, for the sake of meaningful and descriptive variable names, what gives? Does <code>-fextended-identifiers</code> do as it advertises or not? Is it only supported in the very latest build? And what kind of support do other compilers have?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload