我制作了一个包含代码的dll:
#pragma once
extern double __declspec(dllexport) add(double a, double b);
extern double __declspec(dllexport) dif(double a, double b);
#include "testdll.h"
double add(double a, double b)
{
return a + b;
}
double dif(double a, double b)
{
return a - b;
}
调用add函数的python代码:
a = ctypes.c_double(1);
b = ctypes.c_double(2);
mydll = ctypes.CDLL('testDll.dll');
mydll.restype = ctypes.c_double;
ret = mydll.AddNumbers(a, b);
问题是 add 函数不返回 a+b 而是一个搞砸的值:2619340
请帮忙