Suppose in some file a.dll, written in C there are such lines:

typedef void* MyType MyType foo() 

I connect this dll in my Python code. What should I specify in

 lib.foo.restype 

if I want it to always be a MyType type? Ie, taking into account the fact that someday a new version of this a.dll will suddenly come out, where it will be

 typedef void** MyType 

?

PS Of course, I can clearly write

 lib.foo.restype = c_void_p 

and learn about updating the library on time and fix it, but is there a way to do it automatically?

  • Make unit testing of all library functions. If one of the tests fails, go into the code. - ArchDemon
  • @ArchDemon Where do without it :) And yet: really there is no way to say: ...restype = lib.MyType ? - Alexander Chi
  • If the ABI compatibility provided by ctypes is not enough, then use cffi in compatibility API mode - jfs

0