jni jint = int ?

Q

Québec

Hi for ever,

Does the JNI variables can be assigned to C variables
const char * x = (*env)->GetStringUTFChars(env, jstr, &iscopy);
jchar some[4] ;

strcpy(some x); or reverse

for(i=0;i<4;i++){
some = *(x+i);
printf(": %c\n", some);
}
etc ?


Jean
 
Q

Québec

They are the same
printf("tmp == len %d %d %d\n", tmp == len, sizeof(jint), sizeof(int));
true 4 4

Thak you.

Jim Sculley said:
Québec said:
Hi for ever,

Does the JNI variables can be assigned to C variables
const char * x = (*env)->GetStringUTFChars(env, jstr, &iscopy);
jchar some[4] ;

strcpy(some x); or reverse

for(i=0;i<4;i++){
some = *(x+i);
printf(": %c\n", some);
}
etc ?


See: http://java.sun.com/j2se/1.5.0/docs/guide/jni/spec/types.html#wp9502

Jim S.
 
?

=?ISO-8859-1?Q?Daniel_Sj=F6blom?=

Québec said:
They are the same
printf("tmp == len %d %d %d\n", tmp == len, sizeof(jint), sizeof(int));
true 4 4

Thak you.

They only happen to be the same. Don't depend on it if you want your
code to be portable.
 
K

Kevin McMurtrie

If your system is really old, an int is only 16 bits but the jint will
remain 32 bits. A few years from now, int might be 64 bits while jint
is still 32 bits. A C 'int' is typically the CPU's native integer.

This is why some C programs use macro types rather than char, short,
int, long, long long, float, double, extended, etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top