标题:共享变量的赋值发生在模块被导入内存瞬间吗?
只看楼主
vfdff
Rank: 6Rank: 6
等 级:侠之大者
威 望:8
帖 子:2172
专家分:425
注 册:2005-7-15
结帖率:79.17%
 问题点数:0 回复次数:0 
共享变量的赋值发生在模块被导入内存瞬间吗?
刚才 看了MSDN上的 Warning LNK4092  的解说,其中有:
For example, you have a DLL that contains declarations like this in a shared data section:
  Copy Code
int var = 1;
int *pvar = &var;

The linker cannot resolve pvar because its value depends on where the DLL is loaded in memory, so it puts a relocation record in the DLL. When the DLL is loaded into memory, the address of var can be resolved and pvar assigned. If another process loads the same DLL but cannot load it at the same address, the relocation for the address of var will be updated for the second process and the first process's address space will point to the wrong address.
按照这个说法,不同模块导入这同一个DLL时,他们的共享变量值是相等的,而且他们的赋值是在导入时刻被重新计算一次,我英语不好,不知道我的理解对不对??


共享
搜索更多相关主题的帖子: DLL 共享变量 模块 导入 赋值 
2008-10-29 20:01



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-241366-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025785 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved