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)
2.
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 http://blog.tianya.cn/blogger/post_show.asp? Blogid = 1970966 & postid = 16659926