try
{
}
catch(CException* e)
{
e->ReportError(); 
}
__finally 
{
}出错
error C2143: syntax error : missing ';' before '__finally'
是什么问题?代码并没有missing ';'啊

解决方案 »

  1.   

    try {
          f();
       }
       catch (MyException *e) {
          System::Console::WriteLine("in catch");
          System::Console::WriteLine(e->GetType());
       }
       __finally {
          System::Console::WriteLine("in finally");
       }
    msdn的代码
    楼上的  不行啊
      

  2.   

    Microsoft C++ supports two kinds of exception handling: 
      1.C++ exception handling (try, throw, catch) 
      2.Structured exception handling (__try/__except, __try/__finally) Although structured exception handling works with C and C++ source files, it is not specifically designed for C++. For C++ programs, you should use C++ exception handling.Note   In this section, the terms “structured exception handling” and “structured exception” (or “C exception”) refer exclusively to the structured exception handling mechanism provided by Win32. All other references to exception handling (or “C++ exception”) refer to the C++ exception handling mechanism.
      

  3.   

    This is one kind of ask about Structured exception handling for you question:
    __try{
    __try
    {
    }
    __finally
    {
    }
    }
    __except(EXCEPTION_EXECUTE_HANDLER)
    {
    }
      

  4.   

    不匹配, try ... catch 与 __finally 不是一起用的.