## Recommended Posts

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>.\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 on other sites
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 on other sites
Yup! Right before I refreshed the page I added "#include "stdafx.h"" and it compiled!

What's the point of pre-compiled headers on by default?

##### Share on other sites
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 on other sites
Gotcha - Thanks for the fast reply! :)

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
627746
• Total Posts
2978905

• 10
• 10
• 21
• 14
• 14