

![]() | Start a set with this search |
![]() | Include this search in one of my sets |
![]() | Exclude this search from one of my sets |
![]() | Permalink to these results Paste this link in email or IM: |
| Atom feed for tracking future search results Paste this URL into your reader: |
17 messages in net.java.dev.jna.users[jna-users] Array of Structures in a ...| From | Sent On | Attachments |
|---|---|---|
| RWAD...@UP.COM | Jul 18, 2008 8:39 am | |
| Timothy Wall | Jul 18, 2008 9:26 am | |
| RWAD...@UP.COM | Jul 18, 2008 9:46 am | |
| Timothy Wall | Jul 18, 2008 10:18 am | |
| RWAD...@UP.COM | Jul 18, 2008 11:07 am | |
| RWAD...@UP.COM | Jul 18, 2008 11:19 am | |
| Timothy Wall | Jul 18, 2008 11:35 am | |
| Timothy Wall | Jul 18, 2008 11:40 am | |
| Timothy Wall | Jul 18, 2008 11:44 am | |
| Timothy Wall | Jul 18, 2008 11:46 am | |
| RWAD...@UP.COM | Jul 18, 2008 12:01 pm | |
| RWAD...@UP.COM | Jul 18, 2008 12:07 pm | |
| RWAD...@UP.COM | Jul 18, 2008 12:09 pm | |
| RWAD...@UP.COM | Jul 18, 2008 12:28 pm | |
| Timothy Wall | Jul 18, 2008 12:46 pm | |
| RWAD...@UP.COM | Jul 18, 2008 12:55 pm | |
| RWAD...@UP.COM | Jul 18, 2008 1:16 pm |

![]() | Permalink for this message Paste this link in email or IM: |
![]() | Permalink for this thread Paste this link in email or IM: |
| Atom feed for this thread Paste this URL into your reader: |
| Subject: | [jna-users] Array of Structures in a Structure | Actions... |
|---|---|---|
| From: | RWAD...@UP.COM (RWAD...@UP.COM) | |
| Date: | Jul 18, 2008 8:39:12 am | |
| List: | net.java.dev.jna.users | |
I'm having trouble properly initializing a C structure which contains an array of other structures. The C structure definition is:
typedef struct op_and_ornt_struct { Obj_Pnt_Struct obj_pnt; short int num_rpls; struct { Rail_Path_Loca_Struct rpl; Ropo_Struct ropo; double dist_from; } ornt[3]; } Op_And_Ornt_Struct;
____________________________________________________________
The Java code I'm using to emulate this structure is as follows:
package com.uprr.efm.nativ.struct; import java.util.List; import com.uprr.net.Orientation; import com.uprr.point.ObjectPointOrientation;
public class ObjectPointAndOrientationStructure extends Structure {
public ObjectPointStructure obj_pnt ; public int num_rpls ; public OrientationStructure[] orientations ;
/** Default constructor. */ public ObjectPointAndOrientationStructure() { orientations = (OrientationStructure[])new OrientationStructure().toArray(3); } }
____________________________________________________________
I then create a 2-element array of these structures & pass it to a C function as follows:
final ObjectPointAndOrientationStructure opo = new ObjectPointAndOrientationStructure() ; final ObjectPointAndOrientationStructure[] opos = (ObjectPointAndOrientationStructure[])opo.toArray(2); myFunction(opos);
____________________________________________________________
The C function then tries to fill the 2-element "opos" array with zeroes, but crashes. Apparently the Java structure size differs from the C structure size.
I'm guessing that may that the "orientations" array in the structure is not being inlined as intended, & that the Java constructor above is not creating it correctly. Does this make sense? If so, how do i instantiate the 3-element orientation array correctly so that it's inline inside of its parent structure?
.
This message and any attachments contain information from Union Pacific which
may be confidential and/or privileged.
If you are not the intended recipient, be aware that any disclosure, copying,
distribution or use of the contents of this message is strictly prohibited by
law. If you receive this message in error, please contact the sender immediately
and delete the message and any attachments.







