for no apparent reason whatsoever, whenever I try to run my program I get this error
An unhandled exception of type 'System.StackOverflowException' occurred
...and it always points to where I declare my event handler. MyEventReceiver receiver;
Now, in an attempt to figure out wtf is going on, I eliminated my code section by section and found out that this code is causing the problem.
CHARACTER Random_Character()
{
CHARACTER rcharacter;
return(rcharacter);
} // End Random_Character
CHARACTER is a structure of a bunch of different variables, nothing fancy. I get the error if I call this in any way. I tried the simplest way I can think of:
CHARACTER lcharacter = Random_Character();
but I get the overflow error when I call it. Any idea what the problem could be? I've tried rebooting my computer and cleaning the solution etc. also, I made no changes to this code whatsoever before the problem came up.
help pls, I'm stumped
WTF?!? stupid error out of the blue. help pls!
-
- Posts: 61
- Joined: Sun May 08, 2005 11:30 am
A NULL value was return when I receive StackOverFlow error
base on my expereince.
Try to initialize entities in your character class.
e.g.
YourClass::Character
{
int Var1,
int Var2
}
: Var1 ( 0 ), // <<< Initialization
Var2 ( 0 ) // <<< Initialization
{
.
.
.
// your routine
.
.
}
base on my expereince.
Try to initialize entities in your character class.
e.g.
YourClass::Character
{
int Var1,
int Var2
}
: Var1 ( 0 ), // <<< Initialization
Var2 ( 0 ) // <<< Initialization
{
.
.
.
// your routine
.
.
}
AnimaKomix: A Half-3D Packer & Animator
http://www.freewebs.com/project_z/
http://www.freewebs.com/project_z/
-
- Posts: 61
- Joined: Sun May 08, 2005 11:30 am
Another point to node, in Debug mode, at least with Visual Studio, when it runs, it will automatically initializae values for you, like floats to 0.0, and integers to 0, pointers to NULL, etc.
However, in Release mode, if it's not initialized to a value, it's initial value is undefined. So pointers could point to invalid data ( and not 0 ), integers are basically the value of the 4bytes their memory points to, whatever happened to be left in memory, etc.
So, you may not notice so many problems in Debug mode, but you may get crashes and unexpected behavior if you run in Release mode.
However, in Release mode, if it's not initialized to a value, it's initial value is undefined. So pointers could point to invalid data ( and not 0 ), integers are basically the value of the 4bytes their memory points to, whatever happened to be left in memory, etc.
So, you may not notice so many problems in Debug mode, but you may get crashes and unexpected behavior if you run in Release mode.
-
- Posts: 61
- Joined: Sun May 08, 2005 11:30 am
I tried entering 0 for every last value in CHARACTER before returning it, and made sure my compiler was set on debug, and it still doesnt work. I'm not sure exactly what syntax to use to initialize my structures. can someone show me how on this small example structure?
typedef struct HQ
{
wchar_t name[500];
s32 location;
s32 population;
s32 race;
} HQ, *HQ_PTR;
putting (0) or =0 after a variable just gives me an error.
I also made sure that the error occurs whenever I actually return it.
typedef struct HQ
{
wchar_t name[500];
s32 location;
s32 population;
s32 race;
} HQ, *HQ_PTR;
putting (0) or =0 after a variable just gives me an error.
I also made sure that the error occurs whenever I actually return it.
Do the initialisation in the class's constructor...
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java