The following error was encountered at compile time c2061:syntax error:identifier ' This_file '

Source: Internet
Author: User

Write the program in the morning, added a previous write a class, compile encountered the following error:
... error C2061:syntax error:identifier ' This_file '
.../new (+): Error c2091:function returns function
.../new (+): Error C2809: ' operator new ' has no formal parameters
/new: Error c2061:syntax error:identifier ' This_file '
.../new (PNS): Error c2091:function returns function
Very strange, yesterday this kind of test, no problem ah, on the Internet to check a bit, finally found the problem lies.

Workaround:

The newly added class is Cselectserver, which uses the STL, which is called in HouServer.cpp, and is written as follows when HouServer.cpp contains CSelectServer.h files:
#ifdef _DEBUG
#define NEW Debug_new
#undef This_file
static char this_file[] = __file__;
#endif
#include "SelectServer.h"
Search the Internet, found that these errors with the STL header file and VC6 in the CPP file generated in a few lines of code, the STL header file refers to the following lines:

#pragma warning (disable:4786)
#include <list>
using namespace Std;

VC6 several lines of code generated in the CPP file refer to the following lines:

#ifdef _DEBUG
#define NEW Debug_new
#undef This_file
static char this_file[] = __file__;
#endif
The STL header file should be written in VC6 before the several lines of code generated in the CPP file. My "SelectServer.h" file contains the STL header file, when you include "SelectServer.h" file in other CPP files, make sure to place the # include "SelectServer.h" before the lines of VC6 generated. So change to the following to compile through.
#include "SelectServer.h"

#ifdef _DEBUG
#define NEW Debug_new
#undef This_file
static char this_file[] = __file__;
#endif

Summarized in

#ifdef _DEBUG
#define NEW Debug_new
#undef This_file
static char this_file[] = __file__;
#endif

Do not write #include the introduction of the file is error-prone to transfer the # include statement to the front of this conversation



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: info-contact@alibabacloud.com 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.