编译器错误 C3149

“type”:此处没有顶级“char”,不能使用此类型

未正确指定声明。

例如,你可能已在全局范围内定义了 CLR 类型,并已尝试在定义时创建了该类型的变量。 因为不允许使用 CLR 类型的全局变量,所以编译器会生成 C3149。

要解决此错误,请在函数或类型定义中声明 CLR 类型的变量。

下面的示例生成 C3149:

// C3149.cpp
// compile with: /clr
using namespace System;
int main() {
   // declare an array of value types
   array< Int32 ^> IntArray;   // C3149
   array< Int32>^ IntArray2;   // OK
}

下面的示例生成 C3149:

// C3149b.cpp
// compile with: /clr /c
delegate int MyDelegate(const int, int);
void Test1(MyDelegate m) {}   // C3149
void Test2(MyDelegate ^ m) {}   // OK