Re: My ctypes interface fails on OSX 10.8 (Mountain Lion) but works on Red Hat Linux 6

Diez Roggisch <[email protected]> Thu, 13 Sep 2012 12:14:01 +0200
Newsgroups gmane.comp.python.ctypes
Message-ID <CC777E01.28108%[email protected]>
> 
> I've been working on a ctypes interface to udunits2
> (http://www.unidata.ucar.edu/software/udunits/udunits-2/udunits2.html) and
> have hit a strange issue when testing on OSX 10.8 (Mountain Lion).
> 
> I have built a udunits2.so (on Linux) and a udunits2.dylib (on OSx) which I
> can interface to with the attached c code (ud.c) from both the command line
> and via ctypes as per "example1.py". This works great across both Linux and
> OSX.
> 
> However, the point of me using ctypes is to avoid the need for writing the
> wrapping C code, so attempting to replicate "ud.c" with python ctypes code in
> "example2.py" works great on Linux, but results in a udunits failure on OSX.
> 
> I'm not sure what I'm doing wrong, the fact that this code works beautifully
> from C means that I am suspicious about my ctypes code rather than the udunits
> library itself is at fault, but I can't understand why my ctypes code would
> work on one OS and not on the other.
> 
> Should you need it to understand my C code the udunits2 C docs can be found
> here: http://www.unidata.ucar.edu/software/udunits/udunits-2/udunits2lib.html
> 
> I'm using python 2.7.3, udunits 2.1.24 and the builtin ctypes python module on
> both Red Hat 6 and OSX 10.8.
> 
> Does anyone have any idea what I'm doing wrong?


I don't see any "real" ctypes usage here. All I see is loading a lib, and
then using it as if all arguments were integers. Which looks suspicious to
me, and might cause issues because of e.g. Word-size differences under
various OSes. 

So you should try & proper declare function parameters and result  types,
and then try again.

Diez

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

_______________________________________________
ctypes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ctypes-users