Non-standard extension: "XXX" uses Seh, and "XXX" has destructor

Source: Internet
Author: User

If an exception handling mechanism is used in a function, when the VC compiler compiles the function, it inserts some "code and information" into this function (the Code refers to the callback function when an exception occurs in this function, information mainly refers to some necessary linked lists related to exceptions. Therefore, each function can have only one such list ("code and information "), therefore, a function can only use one form of exception handling rules.




The Middle Yellow part is the newly added exception information. The stack unwinding is used to automatically call the destructor of local variables. So the Destructor cannot throw an exception (http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp? Topic%%2fcom.ibm.xlcpp8l.doc%2flanguage%2fref%2fcplr155.htm)
For details about the exception information, see URL.


/**************/
Dry goods 2
/**************/
Well, do you think you understand it? Let's look at the following example:
  1. # Include <stdio. h>
  2. Class
  3. {
  4. Public:
  5. A () {printf ("constructing a object N ");}
  6. ~ A () {printf ("destructor a object N ");}
  7. Void F1 (){}
  8. Void F2 (){}
  9. };
  10. Void main ()
  11. {
  12. _ Try
  13. {
  14. A A1, A2;
  15. Puts ("in try ");
  16. } _ Partition T (puts ("in filter 1"), 1)
  17. {
  18. Puts ("in bytes T 1 ");
  19. }
  20. }

Edit result:
1> C: \ Users \ junliang-Aya \ Documents \ Visual Studio 2008 \ projects \ test \ main. CPP (18): Warning c4509: uses a non-standard extension: "Main" uses Seh, and "A2" has a destructor
1> C: \ Users \ junliang-Aya \ Documents \ Visual Studio 2008 \ projects \ test \ main. cpp (16): see the "A2" Statement
1> C: \ Users \ junliang-Aya \ Documents \ Visual Studio 2008 \ projects \ test \ main. CPP (18): Warning c4509: non-standard extension used: "Main" uses Seh, and "A1" has destructor
1> C: \ Users \ junliang-Aya \ Documents \ Visual Studio 2008 \ projects \ test \ main. cpp (16): see the "A1" Statement
1> C: \ Users \ junliang-Aya \ Documents \ Visual Studio 2008 \ projects \ test \ main. CPP (22): Error c2712: unable to use _ try in the function that requires the object to expand

Why?

As long as a local object exists, the C ++ Exception Handling Mechanism try/catch will certainly exist, and you will call _ Try/_ try t, A function can only have one exception handling mechanism, so an error occurs.

Refer:
Http://baiy.cn/doc/cpp/inside_exception.htm
Http://blog.pfan.cn/mroske/9865.html

Non-standard extension: "XXX" uses Seh, and "XXX" has destructor

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.