编译器错误 C2749
“type”: 使用 /clr:safe 只能引发或捕获托管类的句柄
使用 /clr:safe 时,只能引发或捕获引用类型。
有关详细信息,请参阅 /clr(公共语言运行时编译)。
示例
以下示例生成 C2749:
// C2749.cpp
// compile with: /clr:safe
ref struct MyStruct {
public:
int i;
};
int main() {
MyStruct ^x = gcnew MyStruct;
// Delete the following 4 lines to resolve.
try {
throw (1); // C2749
}
catch(int){}
// OK
try {
throw (x);
}
catch(MyStruct ^){}
}