I heard that it is possible to use Unicode variable names using the -fextended-identifiers
flag in GCC. So I made a test program in C++, but it does not compile.
#include <iostream>
#include <string>
#define ¬ !
#define ≠ !=
#define « <<
#define » >>
/* uniq: remove duplicate lines from stdin */
int main() {
std::string s;
std::string t = "";
while (cin » s) {
if (s ≠ t)
cout « s;
t = s;
}
return 0;
}
I get these errors:
g++ -fextended-identifiers -g3 -o a main.cpp
main.cpp:10:3: error: stray ‘\342’ in program
if (s ≠ t)
^
main.cpp:10:3: error: stray ‘\211’ in program
main.cpp:10:3: error: stray ‘\240’ in program
main.cpp:11:4: error: stray ‘\302’ in program
cout « s;
^
main.cpp:11:4: error: stray ‘\253’ in program
What is going on? Aren't these macro names supposed to work with -fextended-identifiers
?
\uXXXX
and\UXXXXXXXX
. These would be allowed by-fextended-identifiers
. But what you gave are the characters directly. – Cussed