Error C2143 in Visual Studio 2008 (Resolved)

EvilManagedCare

Senior member
Nov 6, 2004
324
0
0
So I'm working on this damnable MFC program for a class using Visual C++. I'm just about done, and hit build solution for hopefully the last time. Imagine my surprise when the compiler error isn't crabbing about one of my own errors, but rather pops out syntax error C2143: missing ';' before 'namespace' This is apparently in 'yvals.h' on line 528, and is part of Visual Studio. I dutifully click on the error and here is the code in question:
Code:
#ifdef __cplusplus
_STD_BEGIN (edit: this is line 528)
typedef bool _Bool;

If you go to the definition of _STD_BEGIN, if it even matters, this is what turns up:
Code:
#if defined(__cplusplus)
  #define _STD_BEGIN	namespace std {
  #define _STD_END		}
  #define _STD	::std::

I included surrounding lines in case this is helpful. I did some searches on google and tried disabling precompiled headers as some recommended, still no luck. I haven't the slightest idea how to proceed, can anyone help? Previous builds of the project compiled and ran just fine. I've gone back and commented out the code I entered prior to this error occuring, but that does not seem to help either. I'm using Visual Studio 2008 Professional.
 
Last edited:

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
What other .h files are included before yvals.h? It's probably a bug in one of yours, like a missing }

Have you been zipping up snapshots of your project as you go? If you aren't using real version control that's the next best thing.
 

EvilManagedCare

Senior member
Nov 6, 2004
324
0
0
What other .h files are included before yvals.h? It's probably a bug in one of yours, like a missing }

Have you been zipping up snapshots of your project as you go? If you aren't using real version control that's the next best thing.

All right, so the wrong course of action would be trying to figure out any problems within yvals.h itself? I realize that's a silly question, but I've had little experience using Visual Studio and have never gotten this specific error before. This all happened late at night, so in my tired state panic set in and I had actually considered trying to find the offending absent ; and adding it. Sounds like this would be a bad idea.

In response to the first question, none of the classes added to this project by me explicitly #include yvals.h. The classes all #include files I added to the project or the includes needed for MFC.

Thanks for the help so far.
 

EvilManagedCare

Senior member
Nov 6, 2004
324
0
0
Dear Lord. I believe I have found the issue: a missing semicolon at the end of a class declaration in an unrelated header file of mine. I'll know for sure after I go home and add it at lunch today.
 
Last edited:

Eckstein

Junior Member
Oct 8, 2007
22
0
0
It is quite common to get compile errors in the libraries when you forget to close regions in your code.
 

EvilManagedCare

Senior member
Nov 6, 2004
324
0
0
You'll all rest easier now knowing the missing semicolon in that seemingly unrelated class declaration was the culprit. All is well now :)

don't ya love C++? :D

It's funny you ask that. Prior to this course I had coded mainly in Java, having maintained an irrational fear of C++. Between the assignments in this class and some miniprojects I did in C++ to prepare myself for this course, a new fondness for C++ has emerged. I could even envision pursuing future endeavors programming in C++ despite a previous devotion to Java. It would seem these C++ assignments have served to desensitize me for the better. At least until another semicolon goes missing :)

Anyway, thanks for input on the problem. Lesson learned: assume the mistake lies with me instead of the file that came packaged in the IDE and worked perfectly fine until then.