Game Programming and Development Tools

Reply to Reply to C++ ... – luke

luke

Member

Posts: 311
From: I use your computer as my second Linux box
Registered: 10-30-2005
Admin: Something is either wrong with the forum, I and some others can't access some topics to reply too (for me they aer the other two C++ ones) and we are stuck making new topics per reply, you might want to look into what the problem is, the error that I get is 'site temprorarily unavailiable' or something like that..

Reply: Thanks, still doesn't work, im going to try using Dev-C++ and see if that works, wouldn't be surprised what with MSVC++.net so darn complicated, one wrong setting can make it impossible to compile

------------------
Omnia Vos Estis Cordatis

dartsman

Member

Posts: 484
From: Queensland, Australia
Registered: 03-16-2006
Wow!!! Are you a "down with windows" guys?? cause I've worked with both VS.Net and Dev-C++, I'd choose VS.Net. If you think VS.Net is hard... lol wait for Dev-C++. Also if your doing the whole "industry standard" then you should use VS.Net anyway :P Plus I wouldn't blame VS.Net, it does compile C++ code :P

This is not a VS.Net thing, this is a C++ thing. Cause you have made your class member variables static. Anywho, you should have used...

#include <iostream>
#include <list>

class MemManagedObj
{
private:
static std::list<MemManagedObj*> m_liveObjects;
static std::list<MemManagedObj*> m_deadObjects;
long m_refCount;
protected:
MemManagedObj();
~MemManagedObj();
public:
void addRef();
void Release();
static void garbageCollect();
};

std::list<MemManagedObj*> MemManagedObj::m_liveObjects;
std::list<MemManagedObj*> MemManagedObj::m_deadObjects;

//using namespace MemManagedObj;

MemManagedObj::MemManagedObj()
{
m_refCount = 0;
}

void MemManagedObj::addRef()
{}

void MemManagedObj::Release()
{}

void MemManagedObj::garbageCollect()
{}

That at least compiles for me, no linker error. You should have looked more into C++ Static Member Variables. Cause I'm guessing you did...

std::list<MemManagedObj*> MemManagedObj::m_liveObjects = 0;

which would have given you an error such as "initializing... cannot convert from 'int' to 'std::list<_Ty>'".

Why did you use this method of object creation?? I would have written it so that there is the object base, to which other objects are derived from, and then an object manager, which handles your objects. Though I do see where your coming from.

And I think thats awesome how you have a "GarbageCollect" function :P hehe

------------------
"But it is God who judges: He brings one down, he exalts another." - Psalm 75:7

luke

Member

Posts: 311
From: I use your computer as my second Linux box
Registered: 10-30-2005
Thanks, Basically what Im trying to do is have a *simple* system that when completed will overload the *(pointer operator) and keep a ref count of any object ( of course you will need to inherit from this object first, but oh well for now) and when the ref count = 0, bam deleted.

Well, thats the idea anyway. I don't want any old object making an actuall MemManagedObj , just objects that have inherited from this, because whats the point of managing the manager if you know what I mean

Oh and it did work, golly I do jump on MS at every chance viva la Linux !
Thanks for helping me!

OOOOOOOOOH! Im soooo stupid, I see, I wasn't even declaring the silly data members only the methods... arg I can't believe I forgot to do that... Im gonna have a nightmare bout that ;D
------------------
Omnia Vos Estis Cordatis

[This message has been edited by luke (edited May 11, 2006).]

[This message has been edited by luke (edited May 11, 2006).]

dartsman

Member

Posts: 484
From: Queensland, Australia
Registered: 03-16-2006
yeah, have you checked out auto pointers??

EDIT: and you only need to declare the static member variables...

------------------
"But it is God who judges: He brings one down, he exalts another." - Psalm 75:7

[This message has been edited by dartsman (edited May 11, 2006).]

luke

Member

Posts: 311
From: I use your computer as my second Linux box
Registered: 10-30-2005
If by auto pointers you mean 'smart' pointers yeah, but if not, Ill take a look. This mem management thing doesn't really seem like its too hard, because so long as its derived from MemManagedObj, then at end of program its gone and certain ones that have smart pointers that point to them will automatically know when to delete themselves =D.

------------------
Omnia Vos Estis Cordatis

dartsman

Member

Posts: 484
From: Queensland, Australia
Registered: 03-16-2006
lol yeah, I call them auto pointers cause of "auto_ptr".

I know what your talking about with the memory manager class, just wanted to see if you have looked into other options as well.

EDIT: BTW, whenever I type the word "auto pointer" I always imagine some super hero saying it... think about it... "Autoo Pointterrrr!!!" haha, And no, I don't actually use them :P I use "SAFE_DELETE" type macros :P

------------------
"But it is God who judges: He brings one down, he exalts another." - Psalm 75:7

[This message has been edited by dartsman (edited May 13, 2006).]

luke

Member

Posts: 311
From: I use your computer as my second Linux box
Registered: 10-30-2005
Well the auto pointers are only there to see if I can delete an object *early* because when proggram closees, everything that is derived from MemManagedObj *will* get deleted, so the sPointers are only there to delete anything that can be deleted early that way no leaks and managed mem =D

------------------
Omnia Vos Estis Cordatis

luke

Member

Posts: 311
From: I use your computer as my second Linux box
Registered: 10-30-2005
Nooo! another (I think) IDE problem...

It says "fatal error C1108: unable to find DLL 'alink.dll'"

I've downloaded the DLL and placed it in several directories full of DLLs except the System32 one.

Before I got this error, I was getting some multiple definitions warnings (but it worked if I put the '/FORCE:MULTIPLE' on the linker command line.

Also, On most of the project properties I dont see ANYTHING the only exceptions are the command line tabs, which seem to be working fine...

------------------
Omnia Vos Estis Cordatis

luke

Member

Posts: 311
From: I use your computer as my second Linux box
Registered: 10-30-2005
Dang, I couldn't edit my above post it kept going to the PM screen weird... anyways..

I did a system restor and the undid the restore, it compiles fine now and the code hasn't changed. But I still can't see any properties other than the command lines. If I do get rid of the '/FORCE:MULTIPLE' option on the linker then I get the error "fatal error LNK1214:initialization failed(80131700)"

------------------
Omnia Vos Estis Cordatis