我有代码:
#define __IGNORE__(...)
#define XUJ(x) ); if (x) { test2(); } __IGNORE__(0
void test2() {
}
void test() {
}
int main() {
int x = 0;
test(XUJ(x));
return 0;
}
GCC 编译,但 cl.exe 有错误:
$ cl 1.cpp
1.cpp(14): error C2059: syntax error: ;
但是...如果我将宏解压缩到:
test(); if (x) { test2(); } __IGNORE__(0);
它编译正常。MSVC 2015 编译器不支持多通道预处理器?O_O
更新:嗯....大括号在哪里?o_O
$ cl /E 1.cpp
1.cpp
#line 1 "1.cpp"
void test2() {
}
void test() {
}
int main() {
int x = 0;
test(); if (x) { test2(); } ;
return 0;
}