9 messages in net.java.dev.jna.usersRe: [jna-users] Need help for beginner
FromSent OnAttachments
Hao JiangFeb 10, 2009 3:16 pm 
Daniel KaufmannFeb 10, 2009 4:58 pm 
Timothy WallFeb 10, 2009 5:00 pm 
Hao JiangFeb 11, 2009 9:08 am 
Hao JiangFeb 11, 2009 12:53 pm 
Timothy WallFeb 11, 2009 2:09 pm 
Timothy WallFeb 11, 2009 2:11 pm 
Hao JiangFeb 11, 2009 2:35 pm 
Hao JiangFeb 12, 2009 9:41 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] Need help for beginnerActions...
From:Timothy Wall (twal@dev.java.net)
Date:Feb 11, 2009 2:11:31 pm
List:net.java.dev.jna.users

Use Structure.toString and set -Djna.dump_memory=true to see the raw contents of the structure memory. This can help you figure out where the structure alignment is going awry.

On Feb 11, 2009, at 3:53 PM, Hao Jiang wrote:

Hi All

I made some progress, I think it's a data type issue (unsigned short in C), my code

typedef struct { char* a; StructA sa; StructB* sb; double c; double d; } Info;

One data type in StructA is unsigned short, I use short in java code

public static class StructA extends Structure{ public int x; public short y}

public static class Info extends Structure{ public String a; public StructA sa; public Pointer sb; public double c; public double d; }

I got error message when run the above code: Invalid memory access

But after comment out y, like this public static class StructA extends Structure{ public int x; // public short y}

I can run the code, and be able to read String a in Info and X in StructA, but I got 0.0 for both c and d which shouldn't be.

How can I mapping unsigned short in java?

Thanks

Hao

*************************************************************************

PRIVILEGE AND CONFIDENTIALITY NOTICE:

The information in this email is intended for the named recipients only.

It may contain privileged and confidential information. If you have

received this communication in error, any use, copying or dissemination

of its contents is strictly prohibited. Please erase all copies of the

message along with any included attachments and notify Intermap

Technologies or the sender immediately by telephone at the number

indicated on this page.