none
VS 2012 Errors RRS feed

  • Question

  • I tried to build my app (VS2010) using VS2012 & it runs ok in release mode, but in debug I get the following 6 errors relating to files I didn’t know I was using;

    1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include\statreg.h(125): error C2061: syntax error : identifier 'nothrow'

    1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include\statreg.h(132): error C2061: syntax error : identifier 'nothrow'

    1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include\atlbase.h(6641): error C2059: syntax error : 'namespace'

    1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include\atlbase.h(6642): error C2143: syntax error : missing ';' before '{'

    1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include\atlbase.h(6642): error C2447: '{' : missing function header (old-style formal list?)

    1>C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\include\atlbase.inl(462): error C2061: syntax error : identifier 'nothrow'

    I'm guessing this is due to a setting in the project properties (as release mode is ok), but does anyone have any clues as to what it might be?

    Thursday, September 27, 2012 3:10 PM

Answers

  • In modern projects, the file stdafx.h is used to increase the speed of compilation. If you do not have such a file, then try defining _ATL_DISABLE_NOTHROW_NEW in Project Properties.

    • Marked as answer by vHappyMan Tuesday, October 2, 2012 8:24 PM
    Tuesday, October 2, 2012 7:03 PM

All replies

  • Show us the settings from Project Properties à C/C++ à Command Line, for Debug and Release.

    Thursday, September 27, 2012 7:04 PM
  • Release command line
    =====================
    /GS /GL /analyze- /W4 /Gy /Zc:wchar_t /I"C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include" /I"C:\Data\DirectX Project\Dongle\inc" /I"C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Samples\C++\DXUT\Core" /I"C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Samples\C++\DXUT\Optional" /Zi /Gm- /O2 /Fd"Release\vc110.pdb" /fp:fast /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "D3DXFX_LARGEADDRESS_HANDLE" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /arch:SSE2 /Gd /Oy /Oi /MD /openmp- /Fa"Release\" /EHsc /nologo /Fo"Release\" /Ot /Fp"Release\WinRanX 1.36.pch" 

    Debug command line
    ==================
    /GS /analyze- /W4 /Zc:wchar_t /I"C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Include" /I"C:\Data\DirectX Project\Dongle\inc" /I"C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Samples\C++\DXUT\Core" /I"C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Samples\C++\DXUT\Optional" /Zi /Gm- /Od /Fd"Debug\vc110.pdb" /fp:fast /D "WIN32" /D "_DEBUG" /D "DEBUG" /D "PROFILE" /D "_CONSOLE" /D "D3DXFX_LARGEADDRESS_HANDLE" /D "_UNICODE" /D "UNICODE" /errorReport:prompt /WX- /Zc:forScope /RTC1 /arch:SSE2 /Gd /Oy- /Oi /MDd /openmp- /Fa"Debug\" /EHsc /nologo /Fo"Debug\" /Fp"Debug\WinRanX 1.36.pch" 
    Thursday, September 27, 2012 8:03 PM
  • Do you have a definition of ‘new’ in your code, for example ‘#define new DEBUG_NEW’?


    Friday, September 28, 2012 6:21 AM
  • Wow I'm impressed, the following lines were automatically inserted when the project was created;

    #ifdef _DEBUG
       #ifndef DBG_NEW
          #define DBG_NEW new ( _NORMAL_BLOCK , __FILE__ , __LINE__ )
          #define new DBG_NEW
       #endif
    #endif  // _DEBUG

    When I comment out this section the build runs fine. Can you please advise what this section does & what are the detriments for not having it? 

    Friday, September 28, 2012 2:46 PM
  • A definition like this is helpful for debugging memory leaks; for example in MFC: http://msdn.microsoft.com/en-us/library/tz7sxz99(v=vs.110).aspx.

    Your problem probably does not occur in new projects created by latest Visual Studio. As a workaround try adding ‘#define _ATL_DISABLE_NOTHROW_NEW’ to stdafx.h or to Project Properties.

    Friday, September 28, 2012 6:13 PM
  • Thank you Viorel_, but one last question (I hope) stdafx.h isn't listed as a program dependency file so I'm assuming modifying that file won't help? & where in the project properties should I insert such a line?
    Friday, September 28, 2012 9:14 PM
  • Thank you Viorel_, but one last question (I hope) stdafx.h isn't listed as a program dependency file so I'm assuming modifying that file won't help? & where in the project properties should I insert such a line?
    What do you mean by 'program dependency file'?
     
    Does each of your .cpp files have
     
    #include "stdafx.h"
     
    as the first non-commented line?
     
    And do you have precompiled headers specified in your project settings?
     

    David Wilkinson | Visual C++ MVP
    Saturday, September 29, 2012 10:07 AM
  • Well I mean that my project doesn't use that file. A search for stdafx.h in my 'entire solution' doesn't return any results & that file name is not listed in the 'External dependency' list.
    Tuesday, October 2, 2012 4:49 PM
  • In modern projects, the file stdafx.h is used to increase the speed of compilation. If you do not have such a file, then try defining _ATL_DISABLE_NOTHROW_NEW in Project Properties.

    • Marked as answer by vHappyMan Tuesday, October 2, 2012 8:24 PM
    Tuesday, October 2, 2012 7:03 PM
  • Well I mean that my project doesn't use that file. A search for stdafx.h in my 'entire solution' doesn't return any results & that file name is not listed in the 'External dependency' list.
    This seems odd, because if VC++ is automatically adding the DEBUG_NEW section to your code I would have thought you have an MFC project, and (to my knowledge) MFC projects always use precompiled headers with the stdafx.h file.
     
    Is this not an MFC project?
     

    David Wilkinson | Visual C++ MVP
    Tuesday, October 2, 2012 8:36 PM
  • I used MFC project and got the same issue. It happen in debug mode, in release mode it is OK.

    After checked the web site, I got a solution.  //blog.hehehehehe.cn/a/17893.htm

    (The edit do not allow me to use a web link, remove http:)

    Modify the following code

    #ifdef _DEBUG
    #define new DEBUG_NEW
    #endif

    change to

    #ifdef _DEBUG
    #define new DEBUG_NEW
    #undef new
    #endif

    • Proposed as answer by Tristan Sun Monday, September 12, 2016 11:51 PM
    Monday, September 12, 2016 11:50 PM
  • That's it you got it. I remmed out the #define new DEBUF_NEW and it works for me.

    Saturday, March 23, 2019 12:58 PM
  • I meant of course #define new DEBUG_NEW’
    Saturday, March 23, 2019 12:59 PM