Results 1 to 6 of 6
- 04-03-2008, 05:12 PM #1
Member
- Join Date
- Apr 2008
- Location
- Indiana
- Posts
- 1
- Rep Power
- 0
Java Native Access (JNA) return types of void *
Hi all,
I'm trying to access a C library in Java and, while going through the various type mappings, I found that one of the functions returns type void *. There didn't appear to be any info on the Java/Native Type Conversions page. Can I safely map to Java's void?
- 01-14-2010, 07:46 PM #2
Member
- Join Date
- Jan 2010
- Posts
- 5
- Rep Power
- 0
Hello burnmd,
I am also stuck at the same place.
Though its been really long since you posted the question, I was wondering if you remember the mapping.
Thanks,
H
- 01-14-2010, 08:25 PM #3
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,603
- Blog Entries
- 7
- Rep Power
- 17
- 01-14-2010, 10:24 PM #4
Member
- Join Date
- Jan 2010
- Posts
- 5
- Rep Power
- 0
Hello JosAH,
Thank you for your quick response.
The variable void* xyz, in my the C code, can point to a data array of any size (char, short, int, long, etc.), including structures of data containing different sized members.
Can I achieve that by using jlong xyz, in jna, where it will be able to point to data array of char, short or a larger data structure?
Thanks,
Regards,
H.
- 01-14-2010, 10:45 PM #5
Member
- Join Date
- Jan 2010
- Posts
- 5
- Rep Power
- 0
JosAH,
How is casting *void xyz into Pointer xyz different from casting it into jlong xyz. When would you choose to use Pointer xyz v/s jlong xyz.
- 01-15-2010, 12:09 AM #6
Member
- Join Date
- Jan 2010
- Posts
- 26
- Rep Power
- 0
Hi H_P i think what JOSAH meant was that a pointer essentially contains a numerical memory reference, so a jlong should be able to preserve the information in the void*.
A quick search I have found an example of the void* being cast to a Pointer and it would seem this is the preferred method.
Documentation - jnaerator - Behaviour of JNAerator for different inputs - Project Hosting on Google Code
This is a jna generator if you have the c header files. The documentation explains the tools casting strategy. From what i have read it will translate void* to Pointer as it is the only option.
I haven't actually played with JNA so take my information as opinion only and perhaps research a little more.Last edited by JavaJuJitZu; 01-15-2010 at 12:10 AM. Reason: Disclaimer
Similar Threads
-
Primitive data types of Java
By Java Tip in forum Java TipReplies: 0Last Post: 03-28-2008, 07:29 PM -
Data compression at 48 Mbyte/s in native Java
By rlasse in forum Java SoftwareReplies: 0Last Post: 03-17-2008, 02:33 AM -
The different of static void,protected,and void in methods?
By Winarto in forum New To JavaReplies: 5Last Post: 01-24-2008, 11:53 PM -
is void a type?
By mary in forum New To JavaReplies: 3Last Post: 08-01-2007, 08:12 PM


LinkBack URL
About LinkBacks


Bookmarks