Solved

ERROR :unexpected end of file while looking for precompiled header directive

Posted on 2001-08-03
4
477 Views
Last Modified: 2013-11-20
I have added new files into My mfc single doc/view project.The listing is as follows

///////////// Myclass.h //////////////////////
#if !defined(AFX_MYCLASS_H__INCLUDED_)
#define AFX_MYCLASS_H__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

class CMyclass : public CObject
{
     CString m_str;
public:
     CMyclass();
     void PrintMsg();
};

#endif // !defined(AFX_MYCLASS_H__INCLUDED_)
/////////////////////// end ///////////////////////



///////////////////////// Myclass.cpp /////////////
#include "Myclass.h"


CMyclass::CMyclass()
{


}
void CMyclass::PrintMsg()
{
     AfxMessageBox("Hello samuel");

}
/////////////////////// end //////////////////////

when i build this project i got the Error:"fatal error C1010: unexpected end of file while looking for precompiled header directive" How to slove it?
0
Comment
Question by:gymsam
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
migel earned 50 total points
ID: 6348209
Hi!
you haveto include header file, used for creation of precompilated header, i the each project file being compiled.
Usually MSVC vizards create stdaf.h file and use it to create precompilated header.
To resolve your problem just rewrite your cpp file:
#include "stdafx.h" //<<!!!
#include "Myclass.h"
CMyclass::CMyclass()
{
}
void CMyclass::PrintMsg()
{
    AfxMessageBox("Hello samuel");
}
/////////////////////// end //////////////////////
0
 
LVL 2

Expert Comment

by:Lockias
ID: 6348888
In some cases you do just need to add #include "stdafx.h" to the .cpp file.  This tells the compiler it is using precompiled headers.  However, there are situations in which you do not wish to use precompile headers.  In this case you need to go to the project settings, find the particular file in the tree on the left, click on the c\c++ tab and select precompiled headers from the combo.  Turn off precompiled headers for the particular file.  Since your are using MFC, in this case you need the first way.
0
 

Author Comment

by:gymsam
ID: 6350909
Thank, i will check your suggestion and get back to you soon.
0
 

Author Comment

by:gymsam
ID: 6358036
Thank you migel.Your suggestion is working fine.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
cat dog challenge 18 127
move a line in eclipse 3 107
Doc'in system (example?) BA 7 115
changeXy challenge 13 88
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

829 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