A strange problem with Visual Studio (error C1075 and C2601) | CodeGuru

A strange problem with Visual Studio (error C1075 and C2601)

Using Visual Studio 2013 C++, I got compilation errors that I couldn’t explain.   The compilation errors were:   [*]*main.cpp(325): error C2601: ‘FLAG’ : local function definitions are illegal   [*]main.cpp(323): this line contains a ‘{‘ which has not yet been matched   [*]main.cpp(326): fatal error C1075: end of file found before the left brace […]

Written By
CodeGuru Staff
CodeGuru Staff
Oct 19, 2014
1 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

Using Visual Studio 2013 C++, I got compilation errors that I couldn’t explain.
 
The compilation errors were:
 

[*]*main.cpp(325): error C2601: ‘FLAG’ : local function definitions are illegal
 
[*]main.cpp(323): this line contains a ‘{‘ which has not yet been matched
 
[*]main.cpp(326): fatal error C1075: end of file found before the left brace ‘{‘ at ‘main.cpp(323)’ was matched*

 
But there was nothing wrong with my code. I counted all brackets and the number matched. There weren’t any function inside another function.

 

I solved it by removing all "//" comments from the source code. It seems that the reason for that is bad line formatting which causes the compiler to miss a line break, so the line after a comment is treated as a comment as well.

 
For example:

// This is a commentThis_is_a_line;

 
is treated as:
 

// This is a commentThis_is_a_line;

 

There are many posts of the net about similar problems and some even suggested that they could be caused by a memory (RAM) fault on the machine, so before you replace your RAM, just remove the comments and see…

— Michael Haephrati

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.