Link to home
Start Free TrialLog in
Avatar of greenbird
greenbird

asked on

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!
Avatar of Priyesh
Priyesh

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?
ASKER CERTIFIED SOLUTION
Avatar of SteveGTR
SteveGTR
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of greenbird

ASKER

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!
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!
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.
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.
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).
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!
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.