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

Hi,

 I have a strange error when compile:

 i declare some functions for class A in CClassA.cpp:

 CClassA::a()
 ..

 i also have the correct CClassA.h file with the declarations.

 now i need to use the functions in CClassB.cpp.

 however it always give me an error:
 fatal error C1010: unexpected end of file while looking for precompiled header directive

 but if i put the function definitions of CClassA in file CClassB.cpp, it works.

 any one can solve the problem? PLS HELP!!!!!!!!!!!!!

 Thanks a lot!
greenbirdAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
SteveGTRConnect With a Mentor Commented:
You must include you precompiled header file at the top of the cpp file (after comments is okay). Mine is stdafx.h, check the classb.cpp file for yours. Or you can look at the settings for an individual file by selecting Project -> Build, select source file, C/C++ tab, select Category: "Precompiled Headers".
0
 
PriyeshCommented:
be specific. what is u'r environment? If it's Vc, check is u have turned on /Yu flag in compiler options, if u try with a simple win32 console app, did u get this error?
0
 
greenbirdAuthor Commented:
Hi,

after i #include"stdafx.h" ( the precompiled head file), it now gives me error message as:

unresolved external symbol "public: static class Comparable<char *> * __cdecl AvlNode<char *>::Insert(class Comparable<char *> *,class AvlNode<char *> * &)"

even though i had declared the function in ClassA.cpp.

what is the error? thanks a lot!
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
greenbirdAuthor Commented:
Hi, Privesh,

no i did not get this error in console application.

but for my exe project, i had turn on /Yu flag, it gives the error message as i described above. ( unresolved external sysmbol).

pls help!

thanks!
0
 
SteveGTRCommented:
Everything is ingored prior to the #include for the precompiled header file. Did you place your #include "classa.h" prior to #include "stdafx.". If so move it after. Like I said, everything is ignored. You can type uncompilable lines above the line and it will be ignored.
0
 
greenbirdAuthor Commented:
Hi, SteveGTR,

i include "ClassA.h" after "stdafx.h". but it still gives me the error of "unsolved external symbol..".

Any Suggestion?

crying... as can not proceed.
0
 
SteveGTRCommented:
I'm not sure... Can you provide a bit of code? From your header file and function as it appears in CPP file (without body of code).
0
 
greenbirdAuthor Commented:
Hi,

ok the files are: ( pls be patient as the header files declarations are quite complicated also)

0) file AvlNode.h
    #ifndef AVLNODE_H
#define AVLNODE_H
#include <stddef.h>
#include "Comparable.h"

template <class KeyType>
class AvlNode {

static   Comparable<KeyType> * Insert(Comparable<KeyType> * item, AvlNode<KeyType> * & root);

static  Comparable<KeyType> * Delete(KeyType key, AvlNode<KeyType> * & root, cmp_t cmp=EQ_CMP);

// the insert func is different
static    Comparable<KeyType> *
   Insert(Comparable<KeyType> * item,
             AvlNode<KeyType> * & root,
             int & change);

   static    Comparable<KeyType> *
   Delete(KeyType key,
             AvlNode<KeyType> * & root,
             int & change,
             cmp_t cmp=EQ_CMP);

1) AvlTree.h
   #include "AvlNode.h"
template <class KeyType> class AvlTree {

Comparable<KeyType> *
   Insert(Comparable<KeyType> * item) {
      return  AvlNode<KeyType>::Insert(item, myRoot);
   }

   Comparable<KeyType> *
   Delete(KeyType key, cmp_t cmp=EQ_CMP) {
      return  AvlNode<KeyType>::Delete(key, myRoot, cmp);
   }
....
} // class definition

2) AvlTree.cpp
   #include "stdafx.h"

#include <stdio.h>
#include <stdlib.h>
#include <cstdio>
#include <iostream.h>
#include <string.h>
#include <string>
 #include <afxdisp.h>
#include <sys/types.h>
#include "AvlTree.h"

then define the above mentioned 4 functions.


3) AnalysisDlg.h
#include "const.h"

#include <iostream.h>
#include "Comparable.h"
#include "AvlTree.h"
#include "colorbtn.h"
#include "ChartDialog.h"
#include "Sxbtn.h"
class CAnalysisDlg : public CDialog
{
public:

    AvlTree<char *> m_tree;
}

4) AnalysisDlg.cpp

void CAnalysisDlg::processDataS(char index){
      
      Comparable<char *> * found = NULL;
      Comparable<char *> *c_ptr;
if (..){
c_ptr = new Comparable<char *>(strdup (nric));
found =m_tree.Insert(c_ptr);

}


and the compile error mesg is:

Linking...
LINK : warning LNK4076: invalid incremental status file "Debug/EyeSys.ilk"; linking nonincrementally

AnalysisDlg.obj : error LNK2001: unresolved external symbol "public: static class Comparable<char *> * __cdecl AvlNode<char *>::Insert(class Comparable<char *> *,class AvlNode<char *> * &)" (?Insert@?$AvlNode@PAD@@SAPAV?$Comparable@PAD@@PAV2@AAPAV1@
@Z)
AnalysisDlg.obj : error LNK2001: unresolved external symbol "public: static class Comparable<char *> * __cdecl AvlNode<char *>::Delete(char *,class AvlNode<char *> * &,enum cmp_t)" (?Delete@?$AvlNode@PAD@@SAPAV?$Comparable@PAD@@PADAAPAV1@W4cmp_t@@@Z
)
Debug/EyeSys.exe : fatal error LNK1120: 2 unresolved externals


pls help! and thank u for ur patience with my qn!
Thank u very much!
0
 
SteveGTRCommented:
Good God, just what I feared templates! I must admit I'm don't know diddley about these beasts.

Having said that I'm now qualified to give totally unqualified suggestions.

The 1st link error looks like it's talking the following line in AnalysisDlg.cpp:

found =m_tree.Insert(c_ptr);

I wonder if you couldn't just make c_ptr at char* and pass it to Insert. I'd do the same with wherever you're using Delete.
0
All Courses

From novice to tech pro — start learning today.