Compiler dependency on ctypes

I have a third-party closed source library, created as a windows dll, created using visual studio 2010. First, I planned to create an extension module for this DLL, for example, SWIG. However, this is spoiled by the fact that it was built with VS 2010, while all python 2 distributions are built with VS 2008.

Now it seems that ctypes does not have this limitation. I built a trivial DLL using VS 2010 (the dependent walker shows what the dll is connected to msvcr100.dll) using the function:

int fnTestLib2(int a, int b)
{
    return a+b;
}

loaded it in ctypes and

fcn = mydll.fnTestLib2
fcn.argtypes = [ctypes.c_int, ctypes.c_int]
fcn.restype = ctypes.c_int
print fcn(1,2)

prints correctly 3.

Now I'm a bit confused: Is it just because I was lucky and because the example is trivial or is there a fundamental difference in the base method ctypesand the extension module? If so, what is it ?;)

: ctypes DLL ?

, distutils Windows SDK. , bla.pyd, . , c runtimes . :

enter image description here

+4
1

SWIG, ctypes, , dll Windows.

. - , mscvr100.dll . , ​​ strlen ( lstrlen, Windows API...):

#include <string.h>
int testfunc(char *str) {
    return strlen(str);
}

, VS2013.

, SWIG ctypes:

  • SWIG C/++ Python
  • ctypes dll Python

ctypes dll, , dll, dll , . , (xxx.a), . , (stdcall cdecl), , windll cdll ().

, SO DLL SWIG Visual Studio 2010, dll Python VisualStudio 2010. , python dll, , - dll Python VisualStudio.

+1

All Articles