I have a fairly complicated project mixing MFC, ATL, and utility classes,
with some files using precopiled headers and some not. About 50% of the
time when I try to compile I get a list of about 24 errors starting with
this:
MainFrm.cpp
e:\program files\microsoft visual studio\vc98\include\crtdbg.h(536) : error
C2833: 'operator DEBUG_NEW' is not a recognized operator or type
e:\program files\microsoft visual studio\vc98\include\crtdbg.h(536) : error
C2059: syntax error : 'newline'
e:\program files\microsoft visual studio\vc98\mfc\include\afx.h(674) : error
C2833: 'operator DEBUG_NEW' is not a recognized operator or type
e:\program files\microsoft visual studio\vc98\mfc\include\afx.h(674) : error
C2059: syntax error : 'newline'
e:\program files\microsoft visual studio\vc98\mfc\include\afx.h(674) : error
C2238: unexpected token(s) preceding ';'
e:\program files\microsoft visual studio\vc98\mfc\include\afx.h(675) : error
C2833: 'operator DEBUG_NEW' is not a recognized operator or type
e:\program files\microsoft visual studio\vc98\mfc\include\afx.h(675) : error
C2059: syntax error : 'newline'
e:\program files\microsoft visual studio\vc98\mfc\include\afx.h(675) : error
C2238: unexpected token(s) preceding ';'
e:\program files\microsoft visual studio\vc98\mfc\include\afx.h(683) : error
C2833: 'operator DEBUG_NEW' is not a recognized operator or type
e:\program files\microsoft visual studio\vc98\mfc\include\afx.h(683) : error
C2059: syntax error : 'newline'
e:\program files\microsoft visual studio\vc98\mfc\include\afx.h(683) : error
C2238: unexpected token(s) preceding ';'
e:\program files\microsoft visual studio\vc98\mfc\include\afx.h(1631) :
error C2833: 'operator DEBUG_NEW' is not a recognized operator or type
e:\program files\microsoft visual studio\vc98\mfc\include\afx.h(1631) :
error C2059: syntax error : 'newline'
Generally, if I recompile immediately, everything is fine. I can also get
rid of these messages by juggling around the order of some include files.
What can I do to get rid of this problem? (I suffered from it on and off
for some years.) What is the magic rule for ordering #includes, #defines,
etc that will make this go away?
Thanks,
Wesley
1. Turn off "Incremental compilation" (Project->Setting->C/C++ tab->Customize category)
2. Use "Automatic Use of Precompiled Header" (Project->Setting->C/C++ tab->Precompiled Headers category)
3. Choose "Not Using Precompiled header" (Project->Setting->C/C++ tab->Precompiled Headers category)
4. Make sure that you have a StdAfx.cpp file where you have "#include StdAfx.h". In the Project settings, choose Precompiled Header category in the C/C++ tab, and
choose "Use precompiled header file (.PCH)" through stdafx.h. Highlight the StdAfx.cpp file and select "Create precompiled header file (.PCH)", and then input
"stdafx.h" in the "Through header" box. For all other files, make sure that you have "Use precompiled header file (.PCH)" is selected with the "stdafx.h" as the "Through
header" entry.
Regards,
Felix Wu
=============
This posting is provided "AS IS" with no warranties, and confers no rights.
Need quick answers to questions like these? The Microsoft Knowledge Base provides a wealth of information that you can use to troubleshoot a problem or answer a
question! It's located at http://support.microsoft.com/support/c.asp?M=F>.
--------------------
>From: "Wesley T Perkins" <wes...@starbath.com>
>Subject: operator DEBUG_NEW' is not a recognized operator or type
>Date: Sun, 20 Jan 2002 17:35:38 -0600
>Lines: 48
>X-Priority: 3
>X-MSMail-Priority: Normal
>X-Newsreader: Microsoft Outlook Express 6.00.2462.0000
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2462.0000
>Message-ID: <OEhAgqgoBHA.1596@tkmsftngp07>
>Newsgroups: microsoft.public.vc.mfc
>NNTP-Posting-Host: adsl-157-6-235.msy.bellsouth.net 66.157.6.235
>Path: cpmsftngxa09!tkmsftngp01!tkmsftngp07
>Xref: cpmsftngxa09 microsoft.public.vc.mfc:309805
>X-Tomcat-NG: microsoft.public.vc.mfc