Error: 'bad _ alloc ': is not a member of 'stlp _ STD'

Source: Internet
Author: User

A compilation error is found when you use ATL to implement a COM:
'Bad _ alloc ': is not a member of 'stlp _ STD'

Remove allCodeFind the problematic code line.
The last line of code can be used to reproduce the error:
# Include <New> // for STD: bad_alloc
...
Throw STD: bad_alloc ();

There is no error in disabling the stlport library and using the native STL library of vc6, but there is a warning:
Warning c4530: C ++ exception handler used, but unwind semantics are not enabled. Specify-GX

The problem seems to be that the GX compilation switch is enabled.
By default, ATL does not enable exception handling, but STL must be used.
It seems that ATL does not encourage the use of STL, or even less CRT, in order to generate the smallest target module.

Refer:
[1] using STL in ATL
[2] issues with using STL classes in ATL COM

(Reprinted pleaseSourceJinqing column)

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.