Advertisement

Problems with MSVC++ 6...

Started by March 08, 2003 01:50 PM
27 comments, last by cippyboy 21 years, 11 months ago
We need a little more code. Does the destination array have enough space? Can you post the variable declarations?

From your description of the error, it sounds like you are overwriting some array. I suspected a stack allocated one because the error msg referenced the stack pointer which implies that you are trashing your stack.
float speed[20];
................
float SPEED[]={0.001f,0.002f,0.003f,0.004f,0.005f,0.006f,0.007f,0.008f,0.009f,0.01f,-0.001f,-0.002f,-0.003f,-0.004f,-0.005f,-0.006f,-0.007f,-0.008f,-0.009f,-0.01f};
//speed=SPEED;
memcpy(speed,SPEED,sizeof(SPEED));
and 3 more like these....

and:

class Enemy{
public :
char Name[10];
MODEL3D *Model;
NEW_ANIMATION *Stay,*Attack_Ani;
int Atk,Defense,Dexterity,Luck,MagicDefense;
...............................//many more
Enemy(){};
};
Enemy EnemySlot[3],EnemyHolder[3];
and :
memcpy(EnemyHolder,EnemySlot,sizeof(EnemySlot));
Should I put EnemySlot[3] or EnemySLot*3 ?
Are the pointers a problem ?

Relative Games - My apps

Advertisement
Could you read the forum faq and use code tags please? Also these are not bugs in msvc, they''re bugs in your code. Garbage in, garbage out.


Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions
It seems you''re deserving all the errors you get. - If you want to be taken serious you should stop writing all this smart-ass stuff and ask proper questions, dude ...

Just my two euro-cents
quote:
Original post by cippyboy
float speed[20];
................
float SPEED[]={0.001f,0.002f,0.003f,0.004f,0.005f,0.006f,0.007f,0.008f,0.009f,0.01f,-0.001f,-0.002f,-0.003f,-0.004f,-0.005f,-0.006f,-0.007f,-0.008f,-0.009f,-0.01f};
//speed=SPEED;
memcpy(speed,SPEED,sizeof(SPEED));
and 3 more like these....


Do you ever try to memcpy the other way? from speed to SPEED? As you have declared it, sizeof(SPEED) != sizeof(speed). See the ridiculous array vs. pointer thread for an explanation why.

quote:

class Enemy{
public :
char Name[10];
MODEL3D *Model;
NEW_ANIMATION *Stay,*Attack_Ani;
int Atk,Defense,Dexterity,Luck,MagicDefense;
...............................//many more
Enemy(){};
};
Enemy EnemySlot[3],EnemyHolder[3];
and :
memcpy(EnemyHolder,EnemySlot,sizeof(EnemySlot));
Should I put EnemySlot[3] or EnemySLot*3 ?
Are the pointers a problem ?


The preferred way of copying data in c++ is by using std::copy(it''s in algorithm), and by defining copy constructors for your classes.

I can''t see anything with the code that you posted that would cause a crash, but you are using suspect coding practices. For example, if you ever derive from Enemy, you could have problems with copying.

Arrays are probably not a good idea, check out std::vector instead. It gives you everything arrays give you, plus copy semantics(you can pass it to a function or assign it, and it will copy the array for you). It also does reallocation if you need to add more items than it can carry. Check it out, it''s in vector
It''s a poor workman that blames his tools.


But... but that''s what HITLER would say!!
Advertisement
I made a for instead of memcpy or anything and I still ge this:
Debug Error!

Program:...Buga Buga.exe//Doesn`t matter->it`s the bugging exe
Module:
File:i386\chkesp.c
Line 42

The value of ESP was not properly saved across a function call. This is usually a result of
callig a function declared with one calling convention with a pointer declared with a
different calling convention .
(Press Retry to debug the application)
Abort Retry Ignore

Relative Games - My apps

Now that you''re using a "for", you can put a breakpoint in at the for (F9 I think), debug your app (F5) and step through it. Hopefully you''ll see the memory you''re trashing.


Helpful links:
How To Ask Questions The Smart Way | Google can help with your question | Search MSDN for help with standard C or Windows functions
Your problems involves pointers over and over again.
Basic rule: Know your pointers!

Grab a book!

This topic is closed to new replies.

Advertisement