2 messages in net.java.dev.jna.usersRe: [jna-users] How do I dereference ...
FromSent OnAttachments
Jorge Nieto-MadridSep 5, 2008 8:28 am 
Timothy WallSep 5, 2008 10:52 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: [jna-users] How do I dereference a Pointer in JavaActions...
From:Timothy Wall (twal@dev.java.net)
Date:Sep 5, 2008 10:52:21 am
List:net.java.dev.jna.users

On Sep 5, 2008, at 11:29 AM, Jorge Nieto-Madrid wrote:

///in C (so easy): typedef struct t_MySmallStruct { int v3d[3]; float v2d[2]; char chr;

///Now in Java ??? public static class MySmallStruct extends Structure { public MySmallStruct() { super(-1, ALIGN_NONE); //or whatever align type } public int[] v3d = {1, 2, 3}; public float[] v2d = {1.1f, 2.2f}; public char chr = 'A';

A Java 'char' is two bytes. A C 'char' is one. Use a Java 'byte' instead.

Pointer pmms = mms.getPointer(); //I think pmms should point to mms!!! pmms.setPointer(0, mms.getPointer());

Read the documentation on usage of Structures. A Java Structure maps to "struct *" in C, in most cases.