ich habe ein Problem bei der Benutzung von Ctypes, im speziellen von double und float variablen. Ich versuche momentan in meinem Pythonprogramm eine C Funktion aufzurufen, was auch mit int Werten klappt, aber bei double scheitert.
Da ich nicht genau weiß, wie ich es formulieren soll, gebe ich einfach mal den Code an.
Funktionierender Code:
C++ Code
Code in Pythonextern "C" __declspec(dllexport) int addition (int zahl1 ,int zahl2)
{
int res = zahl1 + zahl2;
return res;
}
Dieses kleine Programm klappt aber folgendes nicht:def test(wert1, wert2):
Quelle = ctypes.cdll.LoadLibrary("C:\\temp\\pythonfkt.dll")
res = Quelle.addition(wert1,wert2)
print res
test(2,6)
C++
Pythonextern "C" __declspec(dllexport) double multi (double wert1, double wert2)
{
double res = wert1 * wert2;
return res;
}
Kann mir vielleicht jemand weiter helfen?def test2(wert1, wert2):
Quelle = ctypes.cdll.LoadLibrary("C:\\temp\\pythonfkt.dll")
zahl = Quelle.multi(wert1,wert2)
print zahl
test2(3.3,4.5)
Gruß, der Praktikant