Вопрос

I have a DLL from a board I bought to do some stuff, and it defines some functions, constants and types. I have successfully imported it to Python using ctypes. However, from this import I do not have access to the defined constants. For instance, if I need to call a function:

myDLL = ctypes.cdll.LoadLibrary("path/to/dll/parrot.dll")

spam = myDll.eggs(THIS_CONSTANT) #THIS_CONSTANT is defined in the DLL

then I cannot do it. Is there a way to have access to these constants?

Это было полезно?

Решение

#define are certainly not accessible from the DLL. Indeed, their definition is expanded by the preprocessor even before the compiler starts to work. So there is no way the DLL remember the name under which it was defined.

Другие советы

You need to translate the header file into equivalent Python ctypes code. That can be done manually, or perhaps using a tool to automate some or all of the conversion.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top