我正在尝试编写一个脚本来自动化python中的设备.该设备是用C编程的,我现在正在尝试编写一个C包装器,以便我稍后从Python调用这些函数.我正在学习本教程.
原始C函数隐藏在.lib文件中,但提供了包含所有函数初始化的头文件.这是一个它看起来像什么的片段
#ifdef VNX_ATTEN_EXPORTS
#define VNX_ATTEN_API __declspec(dllexport)
#else
#define VNX_ATTEN_API __declspec(dllimport)
#endif
VNX_ATTEN_API void fnLDA_SetTestMode(bool testmode);
VNX_ATTEN_API int fnLDA_GetNumDevices();
VNX_ATTEN_API int fnLDA_GetDevInfo(DEVID *ActiveDevices);
VNX_ATTEN_API int fnLDA_GetModelName(DEVID deviceID, char *ModelName);
VNX_ATTEN_API int fnLDA_InitDevice(DEVID deviceID);
VNX_ATTEN_API int fnLDA_CloseDevice(DEVID deviceID);
VNX_ATTEN_API int fnLDA_GetSerialNumber(DEVID deviceID);
VNX_ATTEN_API int fnLDA_GetDeviceStatus(DEVID deviceID);
Run Code Online (Sandbox Code Playgroud)
这是我试图创建的C包装器
#include <stdio.h>
#include <Python.h>
extern "C" {
#include "VNX_atten.h"
}
//#include <stdafx.h>
/*
* Function to be called from Python
*/
extern "C" {
static PyObject* py_fnLDA_SetTestMode(PyObject* self, PyObject* args)
{
double …Run Code Online (Sandbox Code Playgroud)