Fatal Error C1010:

Posted on 2004-11-29
Last Modified: 2008-02-01

I'm just starting out with classes and i was trying to make one but kept getting this error!! "Unxpected end of file while looking for precomplied header directive. What do you think the error is...what am i doing wrong!?!?!?



#include <iostream>

#include "classTime.h"
using namespace std;

classTime::Time()            // default constructor
      x  = 0;
      y  = 0;
      z  = 0;



#include <iostream>


using namespace std;

class classTime

      int x;
      int y;
      int z;      




//#include "stdafx.h"
#include <conio.h>
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <cstdlib>      
//#include "windows.h"

#include "classTime.h"

using namespace std;

int main()
      return 0;
} // main
Question by:KalluMama
    LVL 3

    Accepted Solution

    I am guessing that you are using Visual Studio.

    Have a look at  "Project>Settings...". The dialog "Project Settings" pops up.

    Select the "C/C++" tab and choose "Precompiled Headers" in the "Category" field.

    Then check the option "Not using precompiled headers" in the page that becomes visible.

    Press "OK" and the error messages should go away.

    Author Comment

    OK, once I do that...I will need to insert #include "stdafx.h" at the top of each file?
    LVL 86

    Expert Comment

    If you set the project to "Not using precompiled headers", you will not have to, but that will cause a speed degradation for not-so-small projects. I'd rather recomend to create an empty file "stdafx.h" and include that one at the top of each source file.
    LVL 3

    Expert Comment

    jkr is right that not using precompiled headers *may* cause a speed degradation for not-so-small projects.

    On the other hand this heavily depends on the overall structure of your system. Since only one "precompiled" header file can be used one tends to "put every (runtime) include file" into this precompiled header file, making the generated precompile quite large. For files that are not using much "external" references this will be a drawback. Also a lot depends on the environment you are using. With a good hard disk and on a "modern" OS (like WinXP) many of the advantage of the precompiled header file go away (e.g. because of file caching etc.)

    (BTW: using an empty "stdafx.h" will not bring any speed improvements)


    Author Comment

    i'm just using real small classes to learn more about em so speed will not be an issue for me...right now its only a question of getting the damn thing straight in my head!!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
    Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
    The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
    The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now