13 messages in net.java.dev.jna.users[jna-users] array of pointers of a st...
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:[jna-users] array of pointers of a struct; Was: [jna-users] "Can't determine size of nested structure"Actions...
From:Zsolt Kúti (kut@t-online.hu)
Date:May 17, 2009 10:32:24 am
List:net.java.dev.jna.users

On Sat, 16 May 2009 21:42:56 -0400 Timothy Wall <twal@dev.java.net> wrote:

...

The C function is: f(struct my_struct *s[])

In Java it becomes: class my_struc extends Structure { ... }

int f(my_struct[] s);

How do you know how big the array is? If you don't know, then you can't safely access even a single element, in C *or* Java.

I know, so I tried to define a large enough array and passed it to f in the hope of seeing something.

If you don't ever access the structure array (i.e. you get it as a result of some other function call), you can just treat it as a Pointer.

I need to access the structure array as the result will be contained in it.

The counterpart of an array of pointers what I need, I just uncertain how to approach that. The API doc says on Structure: When used as a function parameter or return value, this class corresponds to struct*. So I tried passing a variable of my Structure and using its toArray() method with the size that was given back via an IntByReference by the function. This does not seem to work either.

Just to be clear here is the defining C code: struct my_struct int f(struct my_struct *s, int *i)

In usage it looks: static struct my_struct my_s static unsigned int my_i (call) f(&my_s, &my_i) (use) my_s[0]

Zsolt