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

Popular posts from this blog

c++ - Linked List error when inserting for the last time -

java - activate/deactivate sonar maven plugin by profile? -

tsql - Pivot with Temp Table (definition for column must include data type) -- SQL Server 2008 -