python dll return value is wrong -
i have made dll contains code:
#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 + b; } double dif(double a, double b) { return - b; }
the python code calls add function:
= ctypes.c_double(1); b = ctypes.c_double(2); mydll = ctypes.cdll('testdll.dll'); mydll.restype = ctypes.c_double; ret = mydll.addnumbers(a, b);
the problem add function doesnt return a+b screwd value: 2619340
please help
the return type double
, should set restype
so:
hlldll.add.restype = ctypes.c_double hlldll.add.argtypes = [ctypes.c_double, ctypes.c_double]
Comments
Post a Comment