error C1010: unexpected end of file while looking for precompiled header.

Hello!I tried out a program on constructors in VC++ 2008 Express Edition and Turbo C++.On compilation both of them showed 0 errors and 0 warnings.But while running the program VC++ showed:
"fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?" and failed to run.But Turbo C++ ran the program smoothly and showed the output. Could any one tell me what's the reason behind and how to fix the problem?
My code in VC++:

Go into your project settings, C/C++ Compiler, Precompiled headers, and set it to "No precompiled headers" (you may have to use some fuzzy logic to get there, but I'm pretty sure I'm close).

[I also think that if, when you create a project, you select "Empty project" it will automatically select precompiled headers as off, but I'm not sure].

--
Mats

09-22-2008

paushali

Thanks! the first solution didn't work But the second one worked...

09-22-2008

matsp

Quote:

Originally Posted by paushali

Thanks! the first solution didn't work But the second one worked...

I'm sure there is a way to do the first one too - but as long as you have a solution, that'll do, I guess.

[Precompiled headers should really be turned off by default, they only really make sense for LARGE projects, and if you work on a large project, you probably know how to select precompiled headers, so it's just silly to have it on by default].

--
Mats

09-22-2008

Mario F.

Quote:

Originally Posted by paushali

Thanks! the first solution didn't work But the second one worked...

Following the first solution matsp presented you, you must also delete the line including stdafx.h

09-23-2008

paushali

Quote:

Following the first solution matsp presented you, you must also delete the line including stdafx.h

Actually I had also deleted the line containing stdafx.h but when I tried to run the program I got the following errors:
1."stdafx.obj : error LNK2005: "public: __thiscall integer::integer(int,int)" (??0integer@@QAE@HH@Z) already defined in constructor.obj"
2."stdafx.obj : error LNK2005: _main already defined in constructor.obj"
3."C:\Documents and Settings\Dr. D.K.Kundu\My Documents\Visual Studio 2008\Projects\constructor\Debug\constructor.exe : fatal error LNK1169: one or more multiply defined symbols found"

09-23-2008

CornedBee

That sounds like you've got implementations in headers.

09-23-2008

Elysia

You mean you got those errors with or without stdafx.h and mats's solution?
To clarify:
All implementation should be done in source files (.cpp) and class definitions only should be in headers.