Solve the Problem of debug_new: Undeclared identifier

Source: Internet
Author: User

The classes generated using the wizard of VC ++ carry the following lines:

# Ifdef _ debug
# UNDEF this_file
Static char this_file [] =__ file __;
# Define new debug_new
# Endif

Sometimes, when the new operator is used, the error c2065: 'debug _ new': Undeclared identifier is prompted, especially when a new class is defined in ATL/wtl, no problem in release.

There are two solutions:

1. comment out the rows directly.

2. defined before # define new debug_new:
# Define debug_new new (this_file, _ line __)

Cause analysis:

Stdafx. h contains afxwin. H, and afxwin. h contains afx. H, which is defined as follows in the afx. h file:
1. # If defined (_ Debug )&&! Defined (_ afx_no_debug_crt)
3. // memory tracking allocation
4. Void * afx_cdecl operator new (size_t nsize, lpcstr lpszfilename, int nline );
5. # define debug_new (this_file, _ line __)
6. # If _ msc_ver> = 1200
7. Void afx_cdecl operator Delete (void * P, lpcstr lpszfilename, int nline );
8. # endif

In line 3, # define debug_new (this_file, _ line _) appears. Therefore, if it is an MFC program, afxwin. H and afx. H is included, but if it is an ATL program, these two files are not available, so errors are inevitable.

So sometimes this error occurs in the MFC program. Why?

Sometimes you disable the pre-compiled header stdafx. If the system cannot find this definition, an error is reported, resulting in the error c2065: 'debug _ new': Undeclared identifier.
[Tianya blog] address Blogid = 1970966 & postid = 16659926

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: 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.