Why Integer?

This is the place for queries that don't fit in any of the other categories.

Why Integer?

Postby alabview » Tue Oct 29, 2013 2:50 pm

Hi there,

I have no idea why OUT = integer value as I declared it to c_double?

Basically, my DLL is very simple i.e. X + Y = Z

My code as below
Code: Select all
import ctypes
from sys import exit
X = ctypes.c_double(6.97)
Y = ctypes.c_double(5.18)
out=ctypes.c_double()
DLLHANDLE = ctypes.cdll.LoadLibrary("C:\\Walter\\Pyhton_Examples\\Math\\SharedLib.dll")
out = DLLHANDLE.SimpleMath(X,Y)
print("Addition:",out)
exit()


Output result as below,
Code: Select all
>>>
('Addition:', 0)
>>> type (out)
<type 'int'>
>>>


Noticed that, out = int and no idea why???and the out result should be in c_double ie 12.15 but display as 0

Many Thanks.
Walter
alabview
 
Posts: 22
Joined: Mon Sep 16, 2013 1:48 pm

Re: Why Integer?

Postby micseydel » Tue Oct 29, 2013 4:41 pm

We have no idea what's really happening in your DLL, so we can't say why. You'd have to give us that code, and tell us how you created the DLL.
Join the #python-forum IRC channel on irc.freenode.net!

Please do not PM members regarding questions which are meant to be discussed publicly. The point of the forum is so that others can benefit from it. We don't want to help you over PMs or emails.
User avatar
micseydel
 
Posts: 1369
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Re: Why Integer?

Postby Kebap » Tue Oct 29, 2013 5:09 pm

All these threads, you seem to have a lot of trouble with python ctypes. With python int, it would be much easier. My suggestion, in python use int, etc. Only change to ctypes when you address the DLL directly.
Learn: How To Ask Questions The Smart Way
Join the #python-forum IRC channel on irc.freenode.net and chat with uns directly!
Kebap
 
Posts: 396
Joined: Thu Apr 04, 2013 1:17 pm
Location: Germany, Europe


Return to General Coding Help

Who is online

Users browsing this forum: Bing [Bot] and 4 guests

cron