Etienne Gagnon writes: > For one thing, you have not shown me *your* native part. > > Second, see below. > > Andrew Haley wrote: > > > JNIEXPORT void JNICALL > > > Java_somepackage_someNativeMethod > > > (JNIEnv *env, jobject this, jbyteArray nativePointer, ...) > > > > > > { > > > void *ptr; > > > (*env)->GetByteArrayRegion(env, nativePointer, 0, sizeof(void *), (jbyte *) > > &ptr); > > > > Danger, Will Robinson! This is not legal C!!!! You can *not* take > > the address of a pointer and cast it to a jbyte*. > > What's wrong with it? What do you think you are doing, every time you use > malloc(), e.g.: > > buffer = (some cast) malloc(...);
malloc() returns a char*, not a jbyte*. > All I am doing is the same, and is perfectly legal ANSI/ISO C. Sigh. No it isn't, and this code will break with gcc. > Prove me wrong with a specific ISO C specification clause, if you > claim otherwise. I spent a long time working on and supporting gcc, and this is the rule I've had to refer people to more times than any other. It's amazing how many programmers don't know the specfication. All that C guarantees is that you can convert a pointer to a different pointer type and then back again, and the result will compare equal to the original pointer. Also, "when a pointer to an object is converted to a pointer to a character type, the result points to the lowest addressed byte of the object. Successive increments of the result, up to the size of the object, yield pointers to the remaining bytes of the object." Except for this, you may not convert pointers of different type and dereference them. Scetion 6.2.2.3, Para 7. Andrew. _______________________________________________ Classpath mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/classpath