Running but not Working

Started by
5 comments, last by Evil Steve 17 years, 6 months ago
I've been working on this basic code for a week or so and it runs but it runs right through without doing anything (I'm hoping it would display a basic window without DX init'ed) and exits with an extremely odd code (-1073741811) and I never return anything other than bools, 0's, or objects. Code I've been looking it over and over and can't find what's wrong (my strcpy_s are wrong though I know because I have the bit size set to NULL). Can anyone help? (Compiling the files should work fine assuming you start a new blank project and are able to run #include <windows.h> without problems)

=============================RhinoXNA - Easily start building 2D games in XNA!Projects

Advertisement
Well, run it in the debugger and see where and why it exits.
According to my calculator, in Hex, that return code is FFFFFFFFC000000D, which looks suspiciously like uninitialized memory...

Strange seeing that the Run function returns either TRUE or FALSE (which i assume should be 1 and 0)...

BTW, off topic but, the app return code 0 is success and non-zero is failure. So you should edit your main func to return something like this:
return !( App.Run() == TRUE );


Wait a minute... You define two classes, cApp, and cApplication. cApp inheirits from cApplication and overloads 3 virtual functions.
However, you are not calling those functions through a pointer, which means that they are not acting as virtual functions.

Inside "cApplication::Run()" try replacing the lines:

86)if(Init() == TRUE) {
97)if(Frame() == FALSE)
103)Shutdown();

with

86)if(this->Init() == TRUE) {
97)if(this->Frame() == FALSE)
103)this->Shutdown();
Allways question authority......unless you're on GameDev.net, then it will hurt your rating very badly so just shut the fuck up.
Quote:Original post by PhilMorton
According to my calculator, in Hex, that return code is FFFFFFFFC000000D, which looks suspiciously like uninitialized memory...

Strange seeing that the Run function returns either TRUE or FALSE (which i assume should be 1 and 0)...

BTW, off topic but, the app return code 0 is success and non-zero is failure. So you should edit your main func to return something like this:
return !( App.Run() == TRUE );


Wait a minute... You define two classes, cApp, and cApplication. cApp inheirits from cApplication and overloads 3 virtual functions.
However, you are not calling those functions through a pointer, which means that they are not acting as virtual functions.

Inside "cApplication::Run()" try replacing the lines:

86)if(Init() == TRUE) {
97)if(Frame() == FALSE)
103)Shutdown();

with

86)if(this->Init() == TRUE) {
97)if(this->Frame() == FALSE)
103)this->Shutdown();


I tried adding the 'this' 's and it still exited with that same code, and yes I think you're hex is perfectly right and that is the problem. I can't find where it's happening though.

I may have something wrong with my debugger because I put break points in it and none are ever hit, no matter where I put them.

=============================RhinoXNA - Easily start building 2D games in XNA!Projects

Inside a member function, there is absolutley no difference between doing:

FunctionCall();

and

this->FunctionCall();

assuming FunctionCall() is a member of the class. If the functions are virtual, the polymorphic behaviour will be exhibited in either case. When you call a member function, it is always called "via a pointer" since the this pointer is implicit in the first example.

class A{public:    A(){ }    virtual void X(){ }    void Call(){ X(); } // identical to this->X();};class B : public A{public:    B(){ }    void X(){ cout << "B\n"; }};int main(){    B b; b.Call(); // will print "B"    A *a=new B(); a->Call(); // will also print "B"}
I think the error was occurring with my strcpy_s commands because of the bit value. I was assigning it 0 first, then NULL, and now I just set them each to a basic 100 and now it returns with code 1 so I think that fixed that large error because now it's just catching on something else. :p

=============================RhinoXNA - Easily start building 2D games in XNA!Projects

Quote:Original post by programmermattc
I think the error was occurring with my strcpy_s commands because of the bit value. I was assigning it 0 first, then NULL, and now I just set them each to a basic 100 and now it returns with code 1 so I think that fixed that large error because now it's just catching on something else. :p
Passing seemingly random values to any function in the hope it'll work is just asking for trouble. The parameter I think you're referring to should be the size of the buffer you're copying into. If the buffer is 100 chars long, then that's ok. Otherwise, you've successfully circumvented the secure part of strcpy_s() and are just as well using strcpy().

This topic is closed to new replies.

Advertisement