Sign in to follow this  
Basse85

Help with compiling in VC++ Express

Recommended Posts

I've been programming in C# for a few years now and I really love it.
Now I will be learning c++ in school.
I'm used to VC# Express so I downloaded VC++ Express (do you have any other suggestions on a IDE?) and bought Starting out with c++ early objects 7e to get comfortable with the language and IDE, but I have already encountered problems. Even the simplest code won't compile, so I ask you if there is some settings or something else I'm missing.

I'm trying to do a simple console application that will output some text.


#include <iostream>

using namespace std;

int main()
{
cout << "Text";

return 0;
}

The error says: "Error 2 error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source?"

If I do inlcude StdAfx.h I get: "Error 2 error C2065: 'cout' : undeclared identifier"

None of the code in the book compile. Please help.

Another question, how do I activate intellisense in VC++ Express 2010?

EDIT: Removed the code block Edited by Basse85

Share this post


Link to post
Share on other sites
[quote name='Basse85' timestamp='1343752816' post='4964910']The error says: "Error 2 error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source?"[/quote]

When creating a C++ project in Visual Studio, select "Create emtpy project" and uncheck "create precompiled headers". Otherwise, go to your project properties (alt+f7), and navigate to C/C++ -> Precompiled headers, and set "Use precompiled headers" to "do not use".

Share this post


Link to post
Share on other sites
[quote name='fastcall22' timestamp='1343754108' post='4964914']
[quote name='Basse85' timestamp='1343752816' post='4964910']The error says: "Error 2 error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source?"[/quote]

When creating a C++ project in Visual Studio, select "Create emtpy project" and uncheck "create precompiled headers". Otherwise, go to your project properties (alt+f7), and navigate to C/C++ -> Precompiled headers, and set "Use precompiled headers" to "do not use".
[/quote]

that is correct, OR do as the compiler suggests and just add an #include "StdAfx.h" as your first line.

Share this post


Link to post
Share on other sites
[quote name='kunos' timestamp='1343756872' post='4964929']
[quote name='fastcall22' timestamp='1343754108' post='4964914']
[quote name='Basse85' timestamp='1343752816' post='4964910']The error says: "Error 2 error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source?"[/quote]

When creating a C++ project in Visual Studio, select "Create emtpy project" and uncheck "create precompiled headers". Otherwise, go to your project properties (alt+f7), and navigate to C/C++ -> Precompiled headers, and set "Use precompiled headers" to "do not use".
[/quote]

that is correct, OR do as the compiler suggests and just add an #include "StdAfx.h" as your first line.
[/quote]

They already tried that, and that is definitely not the right solution even if it did work.

Share this post


Link to post
Share on other sites
Inellisense should be activated by default, but I also had some problems recently with not showing up. Try to restart your system and try again.
Just for your information, intellisense simply means auto completion. If you write std:: for example it should give you a list of functions and classes within that namespace.
You can also force this by typing Ctrl+J or Ctrl+Space. Just note that the intellisence of c++ is not as advanced as it is in c# and works a little bit differently. In c# when I write 'Con' it will automaticly give me a list beneath where I can select Console, in c++ this is not by default and Im not sure if this can actually be selected. Edited by vleugel

Share this post


Link to post
Share on other sites
[quote name='Basse85' timestamp='1343752816' post='4964910']
I've been programming in C# for a few years now and I really love it.
Now I will be learning c++ in school.
I'm used to VC# Express so I downloaded VC++ Express (do you have any other suggestions on a IDE?) and bought Starting out with c++ early objects 7e to get comfortable with the language and IDE, but I have already encountered problems. Even the simplest code won't compile, so I ask you if there is some settings or something else I'm missing.

I'm trying to do a simple console application that will output some text.


#include <iostream>

using namespace std;

int main()
{
cout << "Text";

return 0;
}

The error says: "Error 2 error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source?"

If I do inlcude StdAfx.h I get: "Error 2 error C2065: 'cout' : undeclared identifier"

None of the code in the book compile. Please help.

Another question, how do I activate intellisense in VC++ Express 2010?

EDIT: Removed the code block
[/quote]

it seems you forgot to place endl; at the end of your cout expression..

it should be[CODE]
#include <iostream>
using namespace std;
int main()
{
cout << "Text" << endl;
return 0;
}
[/CODE]

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