Help with struct arrays
Nicholas Earl <[email protected]> Thu, 26 Sep 2013 21:37:49 -0700
| Newsgroups | gmane.comp.python.ctypes |
|---|---|
| Message-ID | <CANjQ-Uf=_pCruufBQ8eE1sZkHrP42=ttRxy9pNBcb_c5OoP9DQ@mail.gmail.com> |
Hello all! I'm having difficulties accessing the information in a returned
struct object. I'm quite new to C/C++, but I've had plenty of experience
with C#, so I think I have my foot in the door.
I have a struct defined as
class PhotoInfo(ctypes.Structure):
_fields_ = [
('times', ctypes.POINTER(ctypes.c_double)),
('fluxes', ctypes.POINTER(ctypes.c_double)),
]
with the restype defined like
def main():
lib = ctypes.cdll.LoadLibrary('photoroutine.so')
start = lib.start
PhotoInfoPtr = ctypes.POINTER(PhotoInfo)
start.restype = PhotoInfoPtr
But when I call
phin = start()
I can't get to the time and flux info the returned object has. I've tried
using
phin.contents.times
but it just gives me a location; i.e. <__main__.LP_c_double object at
0x159fef0>
How do I get the actual array of times and fluxes?
Thanks for your time!
Nicholas Earl
Graduate Research Assistant
San Diego State University
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
ctypes-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ctypes-users