Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 319
  • Last Modified:

precompiled headers problem

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
g_mcfly
Asked:
g_mcfly
  • 3
  • 3
2 Solutions
 
sunnycoderCommented:
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
 
sunnycoderCommented:
oops ... missed the #endif in your code ...
0
 
sunnycoderCommented:
put #include "stdafx.h" as first line of entity.cpp
0
Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

 
nonubikCommented:
and remove it from entity.h
0
 
nonubikCommented:
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
 
nonubikCommented:
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
 
g_mcflyAuthor Commented:
thanks to both of you
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now