Sign in to follow this  

Running but not Working

This topic is 4098 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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. [url="http://programmermattc.googlepages.com/BaseGameCoreFiles.rar"]Code[/url] 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)

Share this post


Link to post
Share on other sites
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();

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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"
}




Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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().

Share this post


Link to post
Share on other sites

This topic is 4098 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this