编译器错误 C2144
语法错误:“token”的前面应有“type”
编译器想要 token,却找到了 type。
此错误可能是由缺少右大括号、右括号或分号引起的。
尝试从包含空白字符的 CLR 关键字创建宏时,也会发生 C2144。
如果尝试进行类型转发,也可能看到 C2144。 有关详细信息,请参阅转发类型 (C++/CLI)。
示例
以下示例将生成 C2144 并显示了如何修复此错误:
// C2144.cpp
// compile with: /clr /c
#define REF ref
REF struct MyStruct0; // C2144
// OK
#define REF1 ref struct
REF1 MyStruct1;
以下示例将生成 C2144 并显示了如何修复此错误:
// C2144_2.cpp
// compile with: /clr /c
ref struct X {
property double MultiDimProp[,,] { // C2144
// try the following line instead
// property double MultiDimProp[int , int, int] {
double get(int, int, int) { return 1; }
void set(int i, int j, int k, double l) {}
}
property double MultiDimProp2[] { // C2144
// try the following line instead
// property double MultiDimProp2[int] {
double get(int) { return 1; }
void set(int i, double l) {}
}
};