Solved

precompiled headers problem

Posted on 2004-08-31
7
307 Views
Last Modified: 2010-04-24
hi there,

i have a strange problem compiling a very simple project.
details: I have created a new project, console application, not empty project. So i have the files main.cpp, stdafx.cpp , stdafx.h.
Now a simple class is added. Files: entity.h and entity.cpp (through 'Add existing item') Source:

entity.h :

#if !defined(ENTITY_H_)
#define ENTITY_H_

#include "stdafx.h"

using namespace std;

class MM_Entity
{
public:
      MM_Entity( void );
      ~MM_Entity( void );
      bool FromFile( char* filename );

private:
      string m_name;
      string m_pkey;
      vector<string> m_fkeys;
      vector<string> m_attributes;
};

#endif

entity.cpp:

#include "entity.h"

MM_Entity::MM_Entity( void ) : m_fkeys(NULL), m_attributes(NULL)
{

}

MM_Entity::~MM_Entity( void )
{

}

bool MM_Entity::FromFile(char* filename)
{
      return true;
}

Now, when I try to compile I get the error : Unexpected end of file while looking for precompiled header.
Turning off 'Use precompiled header' in project settings ist not the solution. other problems arise then.
What am i missing here?

thanks in advance

mcfly
0
Comment
Question by:g_mcfly
  • 3
  • 3
7 Comments
 
LVL 45

Expert Comment

by:sunnycoder
Comment Utility
Hi g_mcfly,

> #if !defined(ENTITY_H_)
> #define ENTITY_H_

//resst of file

#endif  <-- this is missing ... add #endif as last line of the file

Sunnycoder
0
 
LVL 45

Expert Comment

by:sunnycoder
Comment Utility
oops ... missed the #endif in your code ...
0
 
LVL 45

Accepted Solution

by:
sunnycoder earned 100 total points
Comment Utility
put #include "stdafx.h" as first line of entity.cpp
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 16

Assisted Solution

by:nonubik
nonubik earned 25 total points
Comment Utility
and remove it from entity.h
0
 
LVL 16

Expert Comment

by:nonubik
Comment Utility
Or, if you don't want to use precompiled headers, select entity.cpp in the workspace area, rightclik, select settings, go to C/C++ tab, 'Precompiled headers' in combo, select then 'not using precompiled headers'.
0
 
LVL 16

Expert Comment

by:nonubik
Comment Utility
Do not mind my above comment. :o)

I meant -> rightclick entity.cpp in the solution explorer -> properties -> C/C++ -> precompiled headers -> 'not using...' in first combo
0
 

Author Comment

by:g_mcfly
Comment Utility
thanks to both of you
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

744 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

15 Experts available now in Live!

Get 1:1 Help Now