I'm cursed ...

Started by
15 comments, last by PumpkinPieman 20 years, 3 months ago
it's just a null pointer exception. it means that the pointer you are accessing isn't valid.

after allocating memory from new or whatever always check to see if the pointer is not null

Object * foo = new Object();if (!foo)    handleOutofMemoryError();   


also anytime you are retrieving pointers and running functions you should be checking for null.

Object * obj = getObjectFromSomewhere();if (!obj)    handleNullPointerReturned();   


never assume that pointers you are retrieving are good. it's always possible, esp as your code gets more complex, that you will delete a pointer and then in some other thread, ask for that variable. I'd also get into the habit of setting pointers to NULL after you delete them. otherwise you can be accessing a valid memory space but your object isn't really there. also, always check for NULL when calling delete:

if (objPtr)    delete objPtr;objPtr = NULL;   


and finally always initialize pointers to NULL so they aren't filled with junk data that could also point to valid memory space when it shouldn't:

//class constructorObject::Object(){    memberVarPtr = NULL;}//in a functionvoid main(){    Object * obj = NULL;}  


so yeah, any access violation errors almost always mean you have a bad pointer.

-me

[edited by - Palidine on January 16, 2004 3:13:26 PM]
Advertisement
quote:Original post by PumpkinPieman
Yeah, same error with the downloaded project also.


I don''t see why it''d be trying to link to that library. Did the code for 2a work?


Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena
What compiler are you using? I''ve seen some comments related to that library and Visual Studio .Net 2003.


Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena
quote:Original post by DrunkenHyena
quote:Original post by PumpkinPieman
Yeah, same error with the downloaded project also.


I don''t see why it''d be trying to link to that library. Did the code for 2a work?


Stay Casual,

Ken
Drunken Hyena
No, 2a and 2b gave me the same link error. Yes, I''m currently running default visual studio .net compiler.



quote:Original post by PumpkinPieman
No, 2a and 2b gave me the same link error. Yes, I''m currently running default visual studio .net compiler.


Odd. I found this by doing some searching. I can''t verify that it works right now, but I will check into it in more detail when I get a chance.

Try adding:
/NODEFAULTLIB:libci.lib
to your linker options and see if that helps.


Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena
Yeah that worked, but is there some way I can avoid doing this?

I''ve been doing some research and I have yet to find a good explanation for it. VS.Net is trying to be clever and figure out what you need, and I guess somewhere in the DX8 headers it includes something that makes it think you need io functions linked. Personally I consider this to be a bug, unless someone can provide a better explanation.

So, no it appears that if you use VS.Net to do DX8 stuff you will have to explicitly force it to ignore that library.

Are you really attached to DX8? It might be a good time to consider moving up to DX9.


Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena

This topic is closed to new replies.

Advertisement