Strange
-
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 comment This\_is\_a\_line;
is treated as:
// This is a comment This\_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 מיכאל האפרתי
-
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 comment This\_is\_a\_line;
is treated as:
// This is a comment This\_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 מיכאל האפרתי
I assume this could be a codepage problem. There is an option under Tools/Options/Environment/Documents to save documents in Unicode. Maybe this has a side effect. Also if you (or someone else) edited the source file in some other editor that removed the carriage return from the line break, this could be a problem. I would open the source file in an editor that can show the specific line endings (e.g. Notepad2). Maybe you see something unusual there.
The good thing about pessimism is, that you are always either right or pleasently surprised.
-
I assume this could be a codepage problem. There is an option under Tools/Options/Environment/Documents to save documents in Unicode. Maybe this has a side effect. Also if you (or someone else) edited the source file in some other editor that removed the carriage return from the line break, this could be a problem. I would open the source file in an editor that can show the specific line endings (e.g. Notepad2). Maybe you see something unusual there.
The good thing about pessimism is, that you are always either right or pleasently surprised.
Thanks for the tips. I think one of the source files came from a Mac. Now when I place line breaks, get DEBUG messages, etc. it points to the wrong line and I don't know how to fix that.
- Michael Haephrati מיכאל האפרתי
-
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 comment This\_is\_a\_line;
is treated as:
// This is a comment This\_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 מיכאל האפרתי
Have you considered the possibility of a comment line containing a trigraph? See for example this article[^] on curious errors caused by accidental introduction of trigraphs in comment lines.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)