13 messages in net.java.dev.jna.usersRe: [jna-users] "Can't determine size...
FromSent OnAttachments
Zsolt KútiMay 11, 2009 12:18 pm 
Timothy WallMay 11, 2009 12:22 pm 
Zsolt KútiMay 11, 2009 12:46 pm 
Timothy WallMay 11, 2009 1:06 pm 
Zsolt KútiMay 14, 2009 1:30 pm 
Timothy WallMay 14, 2009 1:58 pm 
Zsolt KútiMay 16, 2009 12:19 pm 
Timothy WallMay 16, 2009 6:42 pm 
Zsolt KútiMay 17, 2009 10:32 am 
Timothy WallMay 17, 2009 10:41 am 
Zsolt KútiMay 17, 2009 11:08 am 
Timothy WallMay 17, 2009 12:47 pm 
Zsolt KútiMay 18, 2009 10:33 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] "Can't determine size of nested structure"Actions...
From:Timothy Wall (twal@dev.java.net)
Date:May 14, 2009 1:58:55 pm
List:net.java.dev.jna.users

bit fields are packed in a compiler-specific manner, but are usually packed together in integer-sized chunks.

you can double check the offsets of your structure's fields by using gcc's offsetof built-in or printing the difference between the field address and the structure base address.

keep checking your field mappings until the structures have the same size; alternatively, if you don't actually need to access the structure's contents, you can just make a single byte[] field of the appropriate size.

On May 14, 2009, at 4:31 PM, Zsolt Kúti wrote:

On Mon, 11 May 2009 16:07:28 -0400 Timothy Wall <twal@dev.java.net> wrote:

It's possible that the native side defines the field in order to effect some sort of alignment or padding of the structure. Compare the size of the Java structure with that of the native structure and ensure that they match. It usually doesn't hurt to make the structure larger than necessary, unless you're using a contiguous array of them.

Other than that, you'll have to examine the JVM dump error log to see where the code failed.

Hi Timothy,

I repaired many defects of my mappings, there remained furthers, however.

Now my test code apparently runs. The function F having the struct[] parameter (S) and an int pointer is called. The int pointer shows what I expect. S however is empty as shown by jna.dump_memory. S for the time being does not contain that empty struct (ES) member. If I put it back complaint for ES having unknown size reappears.

The struct S has many fields with bit length. What is the corresponding Java type of them? There must be a problem here, as the Java struct size almost 10 times that of the C one.