6 messages in net.java.dev.jna.usersRe: [jna-users] Some questions for jna
FromSent OnAttachments
Daniel KaufmannJun 10, 2007 5:41 pm 
Timothy WallJun 10, 2007 6:47 pm 
张久安Jun 10, 2007 7:40 pm 
Timothy WallJun 10, 2007 8:20 pm 
Daniel KaufmannJul 12, 2007 6:20 am.java
Timothy WallJul 12, 2007 8:25 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] Some questions for jnaActions...
From:Timothy Wall (twal@dev.java.net)
Date:Jun 10, 2007 8:20:55 pm
List:net.java.dev.jna.users

(Please don't spam all the lists; if it's a usage oriented question, use the users list, if it has to do with the library internals, use the dev list)

On Jun 10, 2007, at 10:40 PM, 张久安 wrote:

Hello, I am very glad to say it work properly, and i had a try. But if i change the above program to: (hello.dll) struct student{ int age; char * name; void show(); }; void student::showInfo() { printf("name is: %s, age is%d\n", name, age); }

void print(struct student stu) { stu.show(); } then, i can't make it work properly with jna. I wonder is there some idea for me to change the class Structure to support the native struct with function.

There is no explicit C++ support in JNA; you should look at your compiler documentation to determine exactly what the difference is in memory layout between the two versions. It's entirely possible that the C++ object is laid out differently in memory than the C struct.

As for usage, (struct student stu) is not guaranteed to work, you should use (struct student* stu) instead, since structures as argument are not handled consistently across compilers and platforms.