开发者

State of static variable in DLL

Scenario:

My Application bind a library X which has static class. I initialize it in my process. After some time when I load a dll which also use same library X.

I see content of static variable in dll is not initialized. Where I already initialized it in process before loading DLL.

I added initialization code in DLL main , and its working now.

Question : I need to und开发者_如何学JAVAerstand this behavior / case.


library x is clearly linked as a static library against both the exe, and the dll :- in order to get the behavior you want, library X itself needs to be built as a shared library. So then "my application.exe" and "a.dll" would both use "libraryx.dll" as a result there would only by one instance of the static value.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜