error C2061: syntax error : identifier 'THIS_FILE'

3300 단어 MicrosoftGooglemfc
오늘 디지털 이미지 실험 수업의 mfc 코드를 썼는데 stl을 사용했는데 뜬금없는 오류 알림이 한 무더기 나왔다.다음과 같습니다.
인용하다
error C2091: function returns function
d:\program files\microsoft visual studio\vc98\includeew(35) : error C2809: 'operator new' has no formal parameters
d:\program files\microsoft visual studio\vc98\includeew(36) : error C2061: syntax error : identifier 'THIS_FILE'
d:\program files\microsoft visual studio\vc98\includeew(37) : error C2091: function returns function
d:\program files\microsoft visual studio\vc98\includeew(35) : see declaration of 'new'
d:\program files\microsoft visual studio\vc98\includeew(41) : error C2061: syntax error : identifier 'THIS_FILE'
d:\program files\microsoft visual studio\vc98\includeew(42) : error C2091: function returns function
d:\program files\microsoft visual studio\vc98\includeew(35) : see declaration of 'new'
d:\program files\microsoft visual studio\vc98\includeew(42) : error C2809: 'operator new' has no formal parameters
d:\program files\microsoft visual studio\vc98\includeew(42) : error C2065: '_P' : undeclared identifier
d:\program files\microsoft visual studio\vc98\include\memory(16) : error C2061: syntax error : identifier 'THIS_FILE'
d:\program files\microsoft visual studio\vc98\include\memory(17) : error C2091: function returns function
d:\program files\microsoft visual studio\vc98\include\memory(16) : see declaration of 'new'
d:\program files\microsoft visual studio\vc98\include\memory(17) : error C2809: 'operator new' has no formal parameters
d:\program files\microsoft visual studio\vc98\include\memory(20) : error C2954: template definitions cannot nest
그래도 다행이다. 구글이 단번에 나왔어, 응.우리 홈페이지에 가서 보자.
http://support.microsoft.com/default.aspx?scid=kb;en-us;143207
내 경우case2에 속해야 하는데,
바로 이것입니다.
인용하다
Case Two
In addition, you may get this different set of errors:
{include directory}ew.h(80) : error C2061: syntax error : identifier 'THIS_FILE'
{include directory}ew.h(80) : error C2091: function returns function
{include directory}ew.h(80) : error C2809: 'operator new' has no formal parameters#endif
{include directory}ew.h(80) : error C2065: 'ptr' : undeclared identifier
허허, 그리고 해결 방법을 보자.
인용하다
The second set of errors occurs if you add the STL include directive after the following definitions and do not include New.h among your include directives:
   #ifdef _DEBUG
   #define new DEBUG_NEW
   #undef THIS_FILE
   static char THIS_FILE[] = __FILE__;
   #endif
Including New.h will work around this problem as well.
Note that these definitions are no longer necessary in MFC code and can be deleted.
다음과 같이 해결할 수 있습니다.

#include <vector>
#include <algorithm>
using namespace std;
/*
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
*/

std의 그것들을 mFC가 성명한 코드의 앞에 놓거나 MFC 코드를 직접 주석합니다.rebulid all.pass.

좋은 웹페이지 즐겨찾기