编译器错误 C3274
__finally/finally 没有匹配的 try
发现 __finally 或 finally 语句没有匹配的 try
。 若要解决此问题,删除 __finally
语句或为 try
添加 __finally
语句。
以下示例生成 C3274:
// C3274.cpp
// compile with: /clr
// C3274 expected
using namespace System;
int main() {
try {
try {
throw gcnew ApplicationException();
}
catch(...) {
Console::Error->WriteLine(L"Caught an exception");
}
finally {
Console::WriteLine(L"In finally");
}
} finally {
Console::WriteLine(L"In finally");
}
// Uncomment the following 3 lines to resolve.
// try {
// throw gcnew ApplicationException();
// }
finally {
Console::WriteLine(L"In finally");
}
Console::WriteLine(L"**FAIL**");
}