CTypes에서 MSVCRT의 다른 버전
문제
Windows에서 ctypes.cdll.msvcrt
CTYPES 모듈을 가져올 때 객체가 자동으로 존재하며 msvcrt
Microsoft C ++ 런타임 라이브러리 문서에 따르면.
그러나 나는 또한 a가 있음을 알았습니다 find_msvcrt 할 기능 "return the filename of the VC runtype library used by Python"
.
추가 상태, "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
기능? 어떤 상황에서 그들은 같은 도서관이 아닐 수 있습니까?
해결책
그것은 단지 아닙니다 ctypes.cdll.msvcrt
자동으로 존재하지만 ctypes.cdll.anything
자동으로 존재하며 첫 번째 액세스에로드됩니다. anything.dll
. 그래서 ctypes.cdll.msvcrt
잔뜩 msvcrt.dll
, 이것은 창의 일부로 배송하는 도서관입니다. Python이 연결하는 C 런타임이 아니므로 Malloc/Free에서 호출해서는 안됩니다. msvcrt
.
예를 들어, Python 2.6/3.1의 경우 사용해야합니다. ctypes.cdll.msvcr90
. 이것은 시간이 지남에 따라 변하면 find_msvcrt()
실제로 사용해야 할 도서관 이름을 제공합니다 (그리고로드 한 다음으로로드하십시오. ctypes.CDLL
).
다음은 MSC, VC ++, 플랫폼 SDK 또는 Windows의 일부로 다양한 지점에서 출시 된 Microsoft CRT 버전의 이름은 다음과 같습니다. crtdll.dll, msvcrt.dll, msvcrt4.dll, msvcr70.dll, msvcr71. dll, msvcr80.dll, msvcr90.dll.