| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 800 人关注过本帖
标题:共享变量的赋值发生在模块被导入内存瞬间吗?
只看楼主 加入收藏
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
快速回复:共享变量的赋值发生在模块被导入内存瞬间吗?
数据加载中...
 
   



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

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