7 messages in net.java.dev.jna.usersRe: [jna-users] How do I map size_t i...
FromSent OnAttachments
John CaronOct 30, 2008 2:06 pm 
Kunal ShahOct 30, 2008 2:40 pm 
John CaronOct 30, 2008 2:57 pm 
Wayne MeissnerOct 30, 2008 3:27 pm 
John CaronOct 30, 2008 3:35 pm 
Timothy WallOct 31, 2008 4:51 am 
John CaronOct 31, 2008 12:04 pm 
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] How do I map size_t in C to Java?Actions...
From:Timothy Wall (twal@dev.java.net)
Date:Oct 31, 2008 4:51:41 am
List:net.java.dev.jna.users

NativeLong should work in most cases, and if you run into a case where it doesn't, you can conditionalize for a give platform/library combination. Even if sizeof(size_t) were embedded into native code, there's still the possibility that it might be affected by compile- time flags, so there's no magic answer for portability.

On Oct 30, 2008, at 6:35 PM, John Caron wrote:

That's what I thought, but Ive been told that size_t and sizeof(long) might be different, and it depends on the compiler(?).

Wayne Meissner wrote:

2008/10/31 John Caron <car@unidata.ucar.edu>:

I guess on some systems, size_t might be 64 bits, so how can I tell from Java in a portable way?

use NativeLong and NativeLongByReference

A NativeLong is a C 'long' - i.e. 32bits on 32bit systems, 64bit on 64bit unix.

Kunal Shah wrote:

I believe it will be IntByReference since the comment says it's a length.

Thanks!

On Thu, Oct 30, 2008 at 4:06 PM, John Caron <car@unidata.ucar.edu <mailto:car@unidata.ucar.edu>> wrote:

prototype:

int nc_inq_att(int ncid, int varid, const char *name, nc_type *xtypep, size_t *lenp);

example:

int status; /* error status */ int ncid; /* netCDF ID */ int rh_id; /* variable ID */ nc_type vr_type; /* attribute types */ size_t vr_len; /* attribute lengths */

status = nc_inq_att (ncid, rh_id, "valid_range", &vr_type, &vr_len);

thanks for any help, very cool package!