Accessing Array in Struct
Mathias Legerer <[email protected]> Fri, 27 Sep 2013 13:33:20 +0200
| Newsgroups | gmane.comp.python.ctypes |
|---|---|
| Message-ID | <CAEndnobb6fVBB0=D_JZqFHzmEuUtWLNsuxpGb6tgih-DY1NHmg@mail.gmail.com> |
Hi, I have a Struct in C defined like this:
typedef struct _xmySTRUCT
{
char chSomeChar;
<...>
double dProperty[ 10];
double dProptype[ 10];
char szPropname[ 10][ 21];
<...>
} xmySTRUCT, *PxmySTRUCT;
In Python I defined the struct like this:
class MyStructPy(Structure):
_fields_ = [ ("somechar" , c_char )
, ("property" , c_double * 10 )
, ("proptype" , c_double * 10 )
, ("propname" , c_char * 21 * 10 )
]
I let my C-Applicatino load Data in the struct and then I try to read out
the values in Python.
When I try to access the array of doubles, I get some incorrect values (e.g.
0.000000
0.000000
0.000000
0.000000
0.000000
0.000000
2705755772498316500000000000000000000000.000000
2706128776157293300000000000000000000000.000000
2705755777574079800000000000000000000000.000000
0.000000
And strangely the Values in Char-Array all seem to miss the first character.
Thats why I think the problem has something to do with pointers?
I have several such structs in C without Arrays of doubles or Char-Arrays
and they work fine, but these arrays make problems.
Can somebody point me in the direction, what I do wrong?
Thank you,
Mathias
------------------------------------------------------------------------------
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