I’m not a fan of statics but I’ve got some code that has:
The static destruction will fail unless something else is around. The static is declared as a member inside of a DLL class.
The executable is shutting down so runtime calls FreeLibary to release the DLLs it loaded at start up.
I know the static will be destroyed during termination of my program (no guarantees on destruction order since there was no guarantee for construction order) but when will it be be READY for destruction? After my DLLMain (for the loaded DLL) is exited or after the runtimes __DllMainCRTStartup or even after this?
I just want to know if I will get the chance to do something before destruction, if not I will need to look into removing the static to something more appropriate.
Maybe the atexit function will help you. You give it a callback function that will be executed by the runtime during process detach.
DLL Explanation: http://msdn.microsoft.com/en-us/library/988ye33t.aspx
atexit: http://msdn.microsoft.com/en-us/library/tze57ck3.aspx