Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 07-09-2005, 12: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
Old 07-10-2005, 12:24 AM   #2 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,545
Valmont is on a distinguished road
You may have declared pure virtual methods but did not implement them. I can't tell. I really need to see the code.
__________________
Valmont is offline   Reply With Quote
Old 07-10-2005, 12:41 AM   #3 (permalink)
ben657
Registered User
 
Join Date: Jul 2005
Posts: 4
ben657 is on a distinguished road
Yeah, I know you'd probably be able to figure it out right away if I could give out my whole code Trouble is its kind of long, and I'd rather not release it yet anyway.

However, I'm sure I have not used any virtual functions or inheritance anywhere yet.

Is it possible the compiler is in fact having trouble with another part of the code, but doesn't report it yet.
ben657 is offline   Reply With Quote
Old 07-10-2005, 01:18 AM   #4 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,545
Valmont is on a distinguished road
I don't know Borland.

However for Win32 I advice using Dev-Cpp:

See:
http://www.bloodshed.net/devcpp.html
At least these sort of problems are solved then. I never have them. For Linux, KDevelop is my thing.
__________________
Valmont is offline   Reply With Quote
Old 07-10-2005, 02:15 AM   #5 (permalink)
Valmont
[code][/code] enforcer
 
Valmont's Avatar
 
Join Date: Mar 2003
Location: Netherlands
Posts: 1,545
Valmont is on a distinguished road
Besides, see if you can reproduce the problem with reduced code. If you succeed then you should post that. It's the way to do it anyway .
__________________
Valmont is offline   Reply With Quote
Old 07-10-2005, 04:02 PM   #6 (permalink)
ben657
Registered User
 
Join Date: Jul 2005
Posts: 4
ben657 is on a distinguished road
OK, I have got to a point where I can have an instance of a class in the .cpp file for a unit, but not in the header! For example this is fine:

Code:
// ------------------------------
// CEntity.h

#include "CList.h"

class CEntity
{
        void func ();
};

// ------------------------------
// CEntity.cpp

#include "CEntity.h"

void CEntity :: func ()
{
        CList *List;         
}

// ------------------------------
This gives an error:

Code:
// ------------------------------
// CEntity.h

#include "CList.h"

class CEntity
{
        void func ();
};

void CEntity :: func ()
{
        CList *List;         
}

// ------------------------------
The problem is that I have some members of the class that are CList type, so they have to go somewhere in the header.
ben657 is offline   Reply With Quote
Old 07-10-2005, 08:44 PM   #7 (permalink)
ben657
Registered User
 
Join Date: Jul 2005
Posts: 4
ben657 is on a distinguished road
Ah nvm I got it working. Just something small I commented out. I'll need to add it in again later but right now, I'm going to concentrate on making the program work properly. So I'll probably post back at a later time.
ben657 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
coding is not working deepak_kr_mehta Standard C, C++ 2 05-12-2005 03:44 AM
java includes and vars sde Java 6 05-03-2004 06:16 PM
cgi not working on a new script sde PHP 3 05-20-2002 08:29 PM


All times are GMT -8. The time now is 05:36 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting