简体   繁体   English

c ++动态DLL生命周期中的静态变量。 还是为什么他们死了?

[英]c++ Static variables in dynamic DLL lifetime. or why they dead?

so, I load Dll with some global static variables(loggers). 因此,我向Dll加载了一些全局静态变量(记录器)。 and there is no freelibrary. 而且没有免费图书馆。 on close application I call methods from dll but global static variables already destroyed. 在关闭的应用程序上,我从dll调用方法,但全局静态变量已被破坏。 why??? 为什么???

The static variables in the DLL will be destroyed when the DLL is unloaded. 卸载DLL时,DLL中的静态变量将被销毁。 This will happen when the process exits, before the static variables from the main EXE are destroyed, if there is no explicit FreeLibrary call to make it happen earlier. 如果没有显式的FreeLibrary调用使进程更早发生,则在退出主EXE的静态变量之前,进程退出时将发生这种情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM