The following error occurs during compilation: Error c2061: syntax error: identifier 'this _ file'

Source: Internet
Author: User

Note: I encountered an error when referencing my own header file. This method is used to solve the problem.

 

Write in the morningProgramAdded a class written earlier, and encountered the following error during compilation:
... Error c2061: syntax error: identifier 'this _ file'
.../New (35): Error c2091: function returns Function
.../New (35): Error c2809: 'operator new 'has no formal parameters
.../New (36): Error c2061: syntax error: identifier 'this _ file'
.../New (37): Error c2091: function returns Function
It's strange that this class was tested yesterday. No problem. I checked it online and finally found the problem.

Solution:

The newly added class is cselectserver, which uses STL. This class is called in houserver. cpp. When houserver. CPP contains cselectserver. H, it is written as follows:
# Ifdef _ debug
# Define new debug_new
# UNDEF this_file
Static char this_file [] = _ file __;
# Endif
# Include "selectserver. H"
Search through the Internet and find these errors and the lines generated by STL header files and vc6 in the CPP FileCodeThe STL header file refers to the following lines:

# Pragma warning (Disable: 4786)
# Include <list>
Using namespace STD;

The following lines of code generated by vc6 in the CPP file:

# Ifdef _ debug
# Define new debug_new
# UNDEF this_file
Static char this_file [] = _ file __;
# Endif
The STL header file should be written before several lines of code generated by vc6 in the CPP file. Remember! My "selectserver. H "file contains the STL header file. When other CPP files contain" selectserver. H "# include" selectserver. H "before the lines of code generated by vc6! So change to the following to compile and pass.
# Include "selectserver. H"

# Ifdef _ debug
# Define new debug_new
# UNDEF this_file
Static char this_file [] = _ file __;
# Endif

 

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/hzyong_c/archive/2009/02/20/3913692.aspx

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.