Sign in to follow this  
3shirtlessmen

3ShirtlessMen's help thread!

Recommended Posts

3shirtlessmen    169
This is my help thread, since I am picking up C++ again in a new light. I have some experience with it, and I have a bit of programming logic (I can read some code and tell you what it is, or say, how to solve a game related problem(hehe, this one is least of them all!)) Alright, well, I feel like a TOTAL newb now. I bought Beginning C++ through game programming and the darn FIRST "game over" program won't even compile. I'm using Visual C++ 2008 instead of the recommended by the author Bloodshed C++ (last time it was updated was a few years ago and I just think that's a bad idea). Anyway, I'll post my silly compile error and maybe we can get this sorted out! :)
#include <iostream>

int main()
{
	std::cout << "Game Over!" << std::endl;
	return 0;
}



1>------ Build started: Project: GameOver, Configuration: Debug Win32 ------
1>Compiling...
1>GameOver.cpp
1>.\GameOver.cpp(1) : warning C4627: '#include <iosteam>': skipped when looking for precompiled header use
1>        Add directive to 'stdafx.h' or rebuild precompiled header
1>.\GameOver.cpp(6) : error C2653: 'std' : is not a class or namespace name
1>.\GameOver.cpp(6) : error C2065: 'cout' : undeclared identifier
1>.\GameOver.cpp(6) : error C2065: 'std' : undeclared identifier
1>.\GameOver.cpp(6) : error C2143: syntax error : missing ';' before ':'
1>.\GameOver.cpp(6) : error C2143: syntax error : missing ';' before ':'
1>Build log was saved at "NONE OF YO BEEZQWAX"
1>GameOver - 5 error(s), 1 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



My syntax is fine I think. Maybe VB just isn't friendly today?

Share this post


Link to post
Share on other sites
rogierpennink    400
You are using precompiled headers, so it expects you to create and include a file 'stdafx.h'. For small projects such as these it is best to turn off precompiled headers. I do not have visual studio 2008, but in visual studio 2005 you turn it off by going into project properties -> C/C++ -> precompiled headers.

There you will be able to make the project not use them ;)

Regards,

Rogier

Share this post


Link to post
Share on other sites
rogierpennink    400
In large projects you don't want all the standard headers (such as iostream) to be compiled, so using precompiled headers makes sure they're only compiled once. Since you don't typically change such files, the compiler can then skip compiling those in later builds.

However, for such small projects I would definately suggest turning the feature off ;)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this