3 messages in net.java.dev.jna.users[jna-users] problem with the value of...
FromSent OnAttachments
amina guermoucheOct 30, 2008 1:20 am 
Paul LoyOct 30, 2008 2:49 am 
amina guermoucheOct 30, 2008 3:14 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] problem with the value of a float* and intActions...
From:amina guermouche (guer@yahoo.fr)
Date:Oct 30, 2008 1:20:03 am
List:net.java.dev.jna.users

Hello,

I have tow functions in C: void fct1(int rank, float * limit); void fct2(int rank, float limit);

the fct1 will give a value to limit which will be used in fct2

In java, I've called them this way (the fct1 will be: void fct1(int rank,
DoubleByReference limitRef) and the fct2: fct2 (int rank, float limit))

int rank=0; fct1(rank, limitRef) Pointer limitPtr=limitRef.getPointer(); float limit=limitPtr.getfloat(0); System.out.println(limit); //to verify the value of limit rank=0; fct2(rank, limit);

Using this I had 2 problems:

1- I've checked the value that are passed to the C function (by adding a printf
in the C code): for the first function, everything is OK. the value of limit is the same in the fct1 printf and the System.out.println in
java But the printf in fct2 code is different

2- the same for rank (which is just read in both functions) for fct1 it has the same value as in the java code for fct2, it has the value of an uninitialized int

Have I made a mistake in writing my functions? Thanks.