View Single Post
Old 07-09-2005, 01:39 PM   #1 (permalink)
ben657
Registered User
 
Join Date: Jul 2005
Posts: 4
ben657 is on a distinguished road
#includes not working?

Hey, was wondering if you could shed any light on a recurring problem I keep getting. It's hard to explain, but sometimes the #includes I have at the top of a file seem to stop working. An example would be, say I have this code:

// ------------------------------------------
// CList.h

#ifndef CListH
#define CListH

class CList
{
public:
private:
};

#endif

// ------------------------------------------
// CEntity.h

#ifndef CEntityH
#define CEntityH

#include "CList.h"

class CEntity
{
public:
CList *List;
private:
};

#endif

// ------------------------------------------

Now this might compile fine, but later, after making a lot of changes or adding new parts, I might get an error like:

[C++ Error] CEntity.h({line number of CList appearance}): E2450 Undefined structure 'CList'

Sometimes I have managed to have a temporary workaround for the problem, like putting a prototype for the undefined class in the same file (even though it shoudln't be necessary). Then later on I can get away with deleting the prototype, because the #include starts to work again.
And the problem doesn't always happen with classes, it can be functions or just about anything.

So anyway, is there a common cause of this? The compiler I am using is the one included with Borland C++ Builder 6.
ben657 is offline   Reply With Quote