首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ctypes中不同版本的msvcrt

ctypes中不同版本的msvcrt
EN

Stack Overflow用户
提问于 2009-08-28 18:05:30
回答 1查看 2.7K关注 0票数 8

在Windows中,当我导入ctypes模块时,ctypes.cdll.msvcrt对象会自动存在,并且它表示msvcrt微软C++运行时库according to the docs

但是,我注意到还有一个将执行"return the filename of the VC runtype library used by Python"find_msvcrt函数。

它进一步声明,"If you need to free memory, for example, allocated by an extension module with a call to the free(void *), it is important that you use the function in the same library that allocated the memory."

所以我的问题是,我已经拥有的ctypes.cdll.msvcrt库和我可以用find_msvcrt函数加载的库有什么不同?在什么特定情况下,它们可能不是同一个库?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2009-08-28 19:30:12

不仅仅是ctypes.cdll.msvcrt会自动存在,ctypes.cdll.anything也会自动存在,并在第一次访问时加载,加载anything.dll。因此,ctypes.cdll.msvcrt会加载msvcrt.dll,这是一个作为Window一部分提供的库。它不是Python链接的C运行时,所以您不应该从msvcrt调用malloc/free。

例如,对于Python2.6/3.1,您应该使用ctypes.cdll.msvcr90。由于这种情况会随着时间的推移而改变,因此find_msvcrt()会给出您真正应该使用的库的名称(然后通过ctypes.CDLL加载)。

以下是几个不同版本的Microsoft CRT的名称,作为MSC、VC++、platform SDK或Windows的一部分在不同的地方发布: crtdll.dll、msvcrt.dll、msvcrt4.dll、msvcr70.dll、msvcr71.dll、msvcr80.dll、msvcr90.dll。

票数 11
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1348547

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档