Handle C++ exception and structured exception together

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • George2

    Handle C++ exception and structured exception together

    Hello everyone,


    I am learning set_se_translat or, and there are some good resources
    about how to translate structured exception into C++ exception, like,



    1.

    What makes me confused is, when we are talking about translate, it
    means both structured exception and C++ exception may occur in a C++
    program, right?

    2.

    But from build option, we can select either /EHa or /EHsc, means we
    can only select one type of exception, either asynchronous
    (structured) or synchronous (C++ exception).

    (1) and (2) are conflict?


    thanks in advance,
    George
  • anon

    #2
    Re: Handle C++ exception and structured exception together

    George2 wrote:
    Hello everyone,
    >
    >
    I am learning set_se_translat or, and there are some good resources
    about how to translate structured exception into C++ exception, like,
    >

    >
    LOL
    this code looks like coming from a clown:

    catch(CSeExcept ion *e)
    {
    e->ReportError(MB _OK | MB_ICONSTOP);
    e->Delete();
    }

    Wondering what they do in Delete() method. Hope not "delete this"

    BTW http://www.parashift.com/c++-faq-lit....html#faq-17.7 is
    missing that the best way is to catch const reference

    Comment

    • Pavel

      #3
      Re: Handle C++ exception and structured exception together

      George2 wrote:
      Hello everyone,
      >
      >
      I am learning set_se_translat or, and there are some good resources
      about how to translate structured exception into C++ exception, like,
      >

      >
      1.
      >
      What makes me confused is, when we are talking about translate, it
      means both structured exception and C++ exception may occur in a C++
      program, right?
      >
      2.
      >
      But from build option, we can select either /EHa or /EHsc, means we
      can only select one type of exception, either asynchronous
      (structured) or synchronous (C++ exception).
      >
      (1) and (2) are conflict?
      >
      >
      thanks in advance,
      George
      My understanding is that you need to use /EHsc, because your code will
      catch C++ exceptions; the code that throws structured exceptions has
      already been compiled into the libraries your code uses. Did not try it
      myself though.

      -Pavel

      Comment

      • Pavel

        #4
        Re: Handle C++ exception and structured exception together

        anon wrote:
        George2 wrote:
        >Hello everyone,
        >>
        >>
        >I am learning set_se_translat or, and there are some good resources
        >about how to translate structured exception into C++ exception, like,
        >>
        >http://www.codeproject.com/KB/cpp/seexception.aspx
        >>
        >
        LOL
        this code looks like coming from a clown:
        >
        catch(CSeExcept ion *e)
        {
        e->ReportError(MB _OK | MB_ICONSTOP);
        e->Delete();
        }
        >
        Wondering what they do in Delete() method. Hope not "delete this"
        I thought "delete this" was not bad-bad, although certainly not ideal.
        Sometimes there is no good alternative to at least indirect "delete
        this" or its equivalent ... or I simply do not know one. Do you?

        Comment

        • anon

          #5
          Re: Handle C++ exception and structured exception together

          Pavel wrote:
          anon wrote:
          >George2 wrote:
          >>Hello everyone,
          >>>
          >>>
          >>I am learning set_se_translat or, and there are some good resources
          >>about how to translate structured exception into C++ exception, like,
          >>>
          >>http://www.codeproject.com/KB/cpp/seexception.aspx
          >>>
          >>
          >LOL
          >this code looks like coming from a clown:
          >>
          >catch(CSeExcep tion *e)
          >{
          > e->ReportError(MB _OK | MB_ICONSTOP);
          > e->Delete();
          >}
          >>
          >Wondering what they do in Delete() method. Hope not "delete this"
          >
          I thought "delete this" was not bad-bad, although certainly not ideal.
          Sometimes there is no good alternative to at least indirect "delete
          this" or its equivalent ... or I simply do not know one. Do you?


          Do you have an example where "delete this" would be good? Or at least
          not bad?

          Comment

          • Pavel

            #6
            Re: Handle C++ exception and structured exception together

            anon wrote:
            Pavel wrote:
            >anon wrote:
            >>George2 wrote:
            >>>Hello everyone,
            >>>>
            ....
            >>>
            >>LOL
            >>this code looks like coming from a clown:
            >>>
            >>catch(CSeExce ption *e)
            >>{
            >> e->ReportError(MB _OK | MB_ICONSTOP);
            >> e->Delete();
            >>}
            >>>
            >>Wondering what they do in Delete() method. Hope not "delete this"
            >>
            >I thought "delete this" was not bad-bad, although certainly not ideal.
            >Sometimes there is no good alternative to at least indirect "delete
            >this" or its equivalent ... or I simply do not know one. Do you?
            >
            http://www.parashift.com/c++-faq-lit...html#faq-16.15
            Sure, and the synposis of the answer to this FAQ is (quoting):
            "As long as you're careful, it's OK for an object to commit suicide
            (delete this)."
            Do you have an example where "delete this" would be good? Or at least
            not bad?
            virtual Delete() or destroy() function is one of the OK ways to free the
            object's memory (after freeing all other resources owned by the object,
            if any) when the object knows how to free the memory it occupies in most
            general case. When the memory is to be freed via delete, the function
            has to call delete.

            The technique has its pros and contras (IMHO mostly pros) when compared
            with the alternatives I know. Do you know a clearly superior alternative?

            -Pavel

            Comment

            Working...