Ooo Annoying Errors

Started by
20 comments, last by Bimble Bob 18 years, 1 month ago
Ok I have a fwe problems. I was following a tutorial on these forums on how to create a Tetris style game. And I was just building my project when I got these errors: --------------------Configuration: Sky Blocks - Win32 Debug-------------------- Compiling... main.cpp C:\Documents and Settings\Owner\Desktop\Tetris Clone\Sky Blocks\main.cpp(58) : error C2146: syntax error : missing ';' before identifier 'BMap' C:\Documents and Settings\Owner\Desktop\Tetris Clone\Sky Blocks\main.cpp(58) : error C2501: 'BitmapObject' : missing storage-class or type specifiers C:\Documents and Settings\Owner\Desktop\Tetris Clone\Sky Blocks\main.cpp(58) : fatal error C1004: unexpected end of file found Error executing cl.exe. main.obj - 3 error(s), 0 warning(s) Coming from this piece of code: //Structures //This is a structure for shapes struct Shape { int size [4] [4]; int x, y; }; Shape PrevShape; //Uses the Shape structure to create a preview shape to show what shapes next Shape CurrentShape; //Uses the Shape structure to create the current shape being controlled by the player DWORD start_time; //Used for timing bool GameStart = FALSE; //Lets the program know if the game has started //We create two Bitmap Objects using our class. One to handle the whol map (Static Block Array) and one for the current blocks BitmapObject BMap, BBlocks; //Map and Blocks Then... --------------------Configuration: Sky Blocks - Win32 Debug-------------------- Compiling... main.cpp C:\Documents and Settings\Owner\Desktop\Tetris Clone\Sky Blocks\main.cpp(51) : error C2146: syntax error : missing ';' before identifier 'PrevShape' C:\Documents and Settings\Owner\Desktop\Tetris Clone\Sky Blocks\main.cpp(51) : fatal error C1004: unexpected end of file found Error executing cl.exe. main.obj - 2 error(s), 0 warning(s) Which I get after adding a ; (Semi-colon) to the Shape Structure I don't quite understand whats going on. Anybody fancy helping me? Thanks in advance. Oh and if you need to see any classes or anything like that just ask.
It's not a bug... it's a feature!
Advertisement
Double-check and make sure you are putting semicolons at the end of each class (much like with your struct)

ex:

class Foo
{

//stuff
}; //<--BLAM! Semicolon -- right there.

Also, you may have to check EVERYTHING above your line of code that generates the error, including any files (that you created) that are included at the top. Sometimes a compiler can catch an error that actually was caused by code that was written a few lines ABOVE where it thinks the error is.

ex: #include "myfile.h" //<-- check the bottom-most lines of code in this file.
Deep Blue Wave - Brian's Dev Blog.
Quote:C:\Documents and Settings\Owner\Desktop\Tetris Clone\Sky Blocks\main.cpp(51) : fatal error C1004: unexpected end of file found


You're missing a closing brace } somewhere.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Thanks for the quick replys, there is definatly the semi-colon at the end of my class and I shall check my BitmapObject.h file. And I know that the un-expected end of file emans there is mising a closing brace i just don't know where :S
It's not a bug... it's a feature!
The newer IDEs have a really helpful feature: whenever you type a closing brace, it will make it BOLD, as well as the corresponding opening brace. This makes it a lot easier for you to hunt for matching opening/closing braces.
Deep Blue Wave - Brian's Dev Blog.
Hmm I don't think VC++ 6 has this feature, if it doesn can anyone tell me how to get it working? And I still cant seem to find the solutions to anything! 'Tis annoying lol. I think I should mention that my main.cpp does not include any of my "home-made" header files. However BitmapObject.cpp includes my BitmapObject.h file but BitmapObject.cpp compiles fine.
It's not a bug... it's a feature!
That error can also be caused by having the project set to use a precompiled header, but then you failing to include it in your source code.
.
I don't think that's it. I made the project an Empty Win32 Project so...
It's not a bug... it's a feature!
Then in fact that is probably it. MSVC++ by default tends to enable precompiled headers. At least, that has been my experience.
.
Argh, silly VC++. So uhh how do i un-enable them. I'm sorry I'm not really much of an expert.
It's not a bug... it's a feature!

This topic is closed to new replies.

Advertisement