On Fri, 19 May 2000, Boris wrote:
> hello,
> I meet a question in passing argments between java and c.
> In my java program,I call a method in a .dll file and pass a array to it.
> In the .h file that generated by javah,function declaration is followling:
This has probably nothing Linux specific and your environment seems to be
MS Windows, but anyway...
> JNIEXPORT void JNICALL Java_call_aug
> (JNIEnv *, jobject, jlongArray);
>
> I write the following in my c file:
> JNIEXPORT void JNICALL Java_call_aug
> (JNIEnv *env, jobject obj, jlongArray a)
> {
> a[0]=1;
> }
>
> when I build it by vc++,vc++ show the fllowing:
> D:\Boris\args\argdll\arg.cpp(26) : error C2679: binary '=' : no operator defined
>which
> takes a right-hand operand of type 'const int' (or there is no acceptable conversion)
As the error message says: jlongArray class does not define operator= with
right hand operand of type 'const int'. Instead of that you should access
the native long int array encapsulated in the jlongArray object. You
should use functions 'void GetLongArrayElements()' and 'void
ReleaseLongArrayElements()' to access the native long int array.
For example:
jlong *tmp; // Temporal pointer to the native array inside the jlongArray
GetLongArrayElements(env, a, tmp, 0);
tmp[0] = 1; // Here you can access the native array
ReleaseLongArrayElements(env, a, tmp, 0);
For more details see the JNI documentation.
>
> error line is a[0]=1;
>
> How can I pass array ?Or,if I want pass data and want them changed in c ,then
> return,how can i do?
> Thanks
> Boris :-)
Harri
Harri Sunila
Research assistant
Helsinki University of Technology
Telecommunications Software and Multimedia Laboratory
URL: http://www.tcm.hut.fi/~harri
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]