C++ compiling error

Discuss about Programming here. You may release your source, post guide and even ask questions!

Moderator: wizme

Post Reply
ShiunYean
Headmaster of Darkness
Headmaster of Darkness
Posts: 648
Joined: Tue Sep 08, 2009 2:59 pm
Location: Brunei Darussalam
Contact:

C++ compiling error

Post by ShiunYean »

I've been having problem compiling C++ with Microsoft Visual C++ 2010 Express Edition for a long time now.
Here's an example.

My code(Exactly the same as examples in the book):

Code: Select all

#include <iostream>

using namespace std;

int main()
{
	cout << "Hello, I am your computer talking." << endl;
	return 0;
}
And I get this error:

Code: Select all

1>------ Build started: Project: Hello World!!, Configuration: Debug Win32 ------
1>  Hello World!!.cpp
1>e:\cppprojects\helloworld\hello world!!\hello world!!.cpp(1): warning C4627: '#include <iostream>': skipped when looking for precompiled header use
1>          Add directive to 'StdAfx.h' or rebuild precompiled header
1>e:\cppprojects\helloworld\hello world!!\hello world!!.cpp(10): fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "StdAfx.h"' to your source?
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
But when I use the Visual Studio command prompt to compile it, it works perfectly.
Is it something that is wrong with the software?
User avatar
Nerrazzuri
Destiny General
Destiny General
Posts: 1110
Joined: Sun Dec 20, 2009 9:15 pm

Re: C++ compiling error

Post by Nerrazzuri »

add

Code: Select all

 #include "stdafx.h"
on the very top.
Selling my ultimate trainer for MapleStory SEA --> View below for screenshot

Click Here for more Information!

Image
ShiunYean
Headmaster of Darkness
Headmaster of Darkness
Posts: 648
Joined: Tue Sep 08, 2009 2:59 pm
Location: Brunei Darussalam
Contact:

Re: C++ compiling error

Post by ShiunYean »

Thx! I keep trying to add it to the 2nd line, but it didn't work.
I even try adding it after using namespace std;
happy125
Headmaster of Darkness
Headmaster of Darkness
Posts: 549
Joined: Tue Jun 22, 2010 10:06 pm
Location: Singapore

Re: C++ compiling error

Post by happy125 »

just wondering, how come hello world script require another header file? i thought iostream itself is enough already? and if the complier is vc++ shouldnt it be windows.h?
If ur good at smth, never do it for free.
Maple ID list v1.02
Image
Image
Image
User avatar
Nerrazzuri
Destiny General
Destiny General
Posts: 1110
Joined: Sun Dec 20, 2009 9:15 pm

Re: C++ compiling error

Post by Nerrazzuri »

It is the default header for VC++.
Selling my ultimate trainer for MapleStory SEA --> View below for screenshot

Click Here for more Information!

Image
happy125
Headmaster of Darkness
Headmaster of Darkness
Posts: 549
Joined: Tue Jun 22, 2010 10:06 pm
Location: Singapore

Re: C++ compiling error

Post by happy125 »

which means VC++ doesnt include those header files when compling? cause im using GNU GCC complier and hello world just require iostream.
If ur good at smth, never do it for free.
Maple ID list v1.02
Image
Image
Image
User avatar
Nerrazzuri
Destiny General
Destiny General
Posts: 1110
Joined: Sun Dec 20, 2009 9:15 pm

Re: C++ compiling error

Post by Nerrazzuri »

happy125 wrote:which means VC++ doesnt include those header files when compling? cause im using GNU GCC complier and hello world just require iostream.
Thats the precompiler header for VC++
Selling my ultimate trainer for MapleStory SEA --> View below for screenshot

Click Here for more Information!

Image
happy125
Headmaster of Darkness
Headmaster of Darkness
Posts: 549
Joined: Tue Jun 22, 2010 10:06 pm
Location: Singapore

Re: C++ compiling error

Post by happy125 »

i think i got it. thanks for ur help. btw just to let u know that ur link for DLL trainer links to the general programming page instead of the thread.
If ur good at smth, never do it for free.
Maple ID list v1.02
Image
Image
Image
User avatar
Nerrazzuri
Destiny General
Destiny General
Posts: 1110
Joined: Sun Dec 20, 2009 9:15 pm

Re: C++ compiling error

Post by Nerrazzuri »

It is not able to quote the whole thread with '[' and ']' so I just link them to general programming.
Selling my ultimate trainer for MapleStory SEA --> View below for screenshot

Click Here for more Information!

Image
Post Reply