What happens to global variables declared in a DLL?

后端 未结 6 733
眼角桃花
眼角桃花 2020-11-27 14:47

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?

6条回答
  •  孤城傲影
    2020-11-27 15:14

    When DllMain with fdwReason = DLL_PROCESS_DETACH parameter is called it means the DLL is unloaded by the application. This is the time before the destructor of global/static objects gets called.

提交回复
热议问题