Let\'s say I write a DLL in C++, and declare a global object of a class with a non-trivial destructor. Will the destructor be called when the DLL is unloaded?
If you want to see the actual code that gets executed when linking a .dll, take a look at %ProgramFiles%\Visual Studio 8\vc\crt\src\dllcrt0.c.
%ProgramFiles%\Visual Studio 8\vc\crt\src\dllcrt0.c
From inspection, destructors will be called via _cexit() when the internal reference count maintained by the dll CRT hits zero.
_cexit()