下面一段程序在使用gcc test.cpp -o test进行编译的时候无法编译通过,报错
error:expected class-name before ';' token
而将int compl改为 int xx就正常。
//test.cpp
typedef struct
{
int compl;
int somebody;
} TestSt;
int main()
{
TestSt test;
return 0;
}
查看gcc手册发现这个符号为keyword:
-fno-operator-names Do not treat the operator name keywords "and", "bitand", "bitor", "compl", "not", "or" and "xor" as synonyms as keywords.
使用下面方法编译就正常:
gcc-fno-operator-namestest.cpp -o test