In my DLL, I have a static vector defined in the global scope, and whenever I call a function that uses the vector the program crashes because the size of the vector is 0 when the function is called. The vector has had a value pushed onto it before, and I've even had a MessageBox come up to show what the size of the vector is after the call to push_back(), and it gave me a size of one. At no point am I ever calling any pop_ functions.
I also copied the code into a Win32 Console application project, and after removing all of the __declspecs, I ran a test. It didn't crash, and it gave me all of the values it was expected to. So are static variables to blame in this case? I'd rather not post the code since it's 150+ lines and would look bulky.
your dll might be loading and when you are done it my be unloading. now when you call it next time all your variables will be unset as the dll may load again. this might be the cause. I think you use loadlibrary and then unload the dll when you are done. i think this may work. are you able to debug the dll and see whats going on?
writetonsharma: I'm able to use the Visual Studio debugger to see where the program is crashing, but it was only able to show me that the vector is being emptied at some point. I've also tried having it a static member of a class, no difference. So I'm guessing that it's not because it's constantly being loaded and unloaded. Plus, it was working before. I added a couple of new arguments to make the function more customizable, but I didn't do anything else before it began to crash.
kbw: The static variable is only used within the DLL. I don't think it needs to be exported.
Alright, give me a while. For some reason it's giving me errors now whenever I compile. >.>
EDIT: Well, since god hates me, my classes aren't recognizing each other any more and I get errors whenever I try to compile. I'll post again when I have it working... er, well, compiling.
I have a feeling that the whole problem is just because I accidentally removed a function or forgot a semicolon. The whole thing worked fine until I added the arguments to that one function... >.>