Exit code 3

Started by
12 comments, last by HinataHyuga 17 years, 3 months ago
I have an error in my program and its exiting with code 3 see here: The program '[800] Engine Test.exe: Native' has exited with code 3 (0x3). but it should exit with code 0. what does an exit code of 3 mean? Thanks Hinata
Advertisement
Exit Codes

(One of the first things Google came up with.
I dont understand how that can be but thank you verrry much;
-Hinata
Alright, here's a tip. Find a good debugger. Let's assume you use Visual C++. Place a break point near the beginning of the program. Now, step through every line of code, one by one. Continue going on, and you'll eventually crash. Look at the line where you crash.

I suggest you learn to debug your code, as it will make development a lot easier.
i know where my error is but i dont know why i'm getting it it is here:
void EObject::Cleanup(){	ofstream file("debug.txt",ios::app);	file<<"DeleteingObjects"<<endl;	if(LiveObjects.size() > 0)	for(list<EObject *>::iterator i = LiveObjects.end(); i != LiveObjects.begin();i--){		file<<"Deleting live object!"<<endl;		EObject *obj = *i;		delete obj;<------------------------------------HEREEEEEEEEE	}	if(DeadObjects.size() > 0)	for(list<EObject *>::iterator c = DeadObjects.end(); c != DeadObjects.begin();c--){		file<<"Deleting dead object!"<<endl;		EObject *obj = *c;		delete obj;	}	if(LiveObjects.empty()){		file<<"LiveObjects deleted successfully."<<endl;	}	else{		file<<"Error deleting live objects!"<<endl;	}	if(DeadObjects.empty()){		file<<"DeadObjects deleted successfully."<<endl;	}	else{		file<<"Error deleting dead objects!"<<endl;	}	file<<"Deletion complete!"<<endl;	file.close();}

here is my class.h file:
#ifndef EOBJECT_H#define EOBJECT_H#include<list>#include<fstream>using namespace std;class EObject{private:	static list<EObject *> LiveObjects;	static list<EObject *> DeadObjects;	int refcount;protected:	EObject();	virtual ~EObject();public:	int GetRefCount();	void AddRef();	void Release();	static void CollectGarbage();	static void Cleanup();};#endif

Thanks nyteguard
-Hinata
EDIT: yes i do use vc++
	for(list<EObject *>::iterator i = LiveObjects.end(); i !=LiveObjects.begin();i--){		file<<"Deleting live object!"<<endl;		EObject *obj = *i;		delete obj;<------------------------------------HEREEEEEEEEE	}

list<EObject *>::iterator i = LiveObjects.end(); Will point to the first empty space at the end of the list. So when you try to dereference i and assign it to *obj that's where the error is occurring.

Either start from the beginning of the list with something like this

	for(list<Planet*>::iterator i = planets.begin(); i != planets.end();i++){		file<<"Deleting live object!"<<endl;		Planet *obj = *i;		delete obj;	}

Or use a reverse iterator instead. I suggest carefully reading an stl reference before you use the reverse iterator because i++ for a reverse iterator makes you go backwards through the list, which to me wasn't what I was expecting when I was being confused by lists two days ago. :)

[Edited by - Eagle32 on January 2, 2007 8:05:40 PM]
i'm following the code in the enginuity article i thought it would work?
-Hinata
OK start from the beginning,
The way you are removing objects is wrong as has been stated and I would suspect you have other problems in the member functions not shown.
to remove try
Quote:
for(std::list<EObject*>::iterator i = LiveObjects.begin(); i != LiveObjects.end(); )
{
EObject* o = *i;//dereference the iter
i = LiveObjects.erase(i);//remove the object from the list and increment the iter
delete o;//recovery memory
}


Hint a typedef in the class would be nice you that you don't have to keep typing the type of container. What also concerns me is the line
Quote: if(LiveObjects.size() > 0)
why is this there you are dealing with iterators and there should be no need for it.?

Quote: i'm following the code in the enginuity article i thought it would work?
It more than likely does, but have you followed it closely?
i followed section 2 closely and am trying to build off of it. sorry also this:
for(list<EObject *>::iterator i = LiveObjects.begin(); i != LiveObjects.end();){		EObject* o = *i;//dereference the iter		i = LiveObjects.erase(i);//remove the object from the list and increment the iter		delete o;//recovery memory	}

doesnt work for me still same error.
I derive a EBitmap class from the EObject class and have a constructor and all for it that is the only object that i am making.EBitmap bit1("mybitmap.bmp",500,500);
and my program exits with code 3 every time. its very frustrating :-/
-Hinata
Quote:Original post by dmail
OK start from the beginning,
The way you are removing objects is wrong as has been stated and I would suspect you have other problems in the member functions not shown.
to remove try
Quote:
for(std::list<EObject*>::iterator i = LiveObjects.begin(); i != LiveObjects.end(); )
{
EObject* o = *i;//dereference the iter
i = LiveObjects.erase(i);//remove the object from the list and increment the iter
delete o;//recovery memory
}


Hint a typedef in the class would be nice you that you don't have to keep typing the type of container. What also concerns me is the line
Quote: if(LiveObjects.size() > 0)
why is this there you are dealing with iterators and there should be no need for it.?

Quote: i'm following the code in the enginuity article i thought it would work?
It more than likely does, but have you followed it closely?

I dont know how to use typdefs :-/
-Hinata

This topic is closed to new replies.

Advertisement