Hi,
I have a C++ JNI problem. Below code doesn't compile in VC++ (VS2010).
It's part of a C++ dll, that's called from a Java program.
1 2 3 4 5 6 7 8 9 10 11 12 13
|
#include <jni.h>
#include <stdio.h>
#include "TestJNIString.h"
JNIEXPORT jstring JNICALL Java_TestJNIString_sayHello(JNIEnv *env, jobject thisObj, jstring inJNIStr) {
const char *inCStr = env->GetStringUTFChars(inJNIStr, NULL);
if (NULL == inCSt) return NULL;
printf("In C, the received string is: %s\n", inCStr);
env->ReleaseStringUTFChars(inJNIStr, inCStr);
char outCStr[128];
printf("Enter a String: ");
scanf("%s", outCStr);
return env->NewStringUTF(outCStr);
}
|
However building it in VC++ gives a number of errors :
Error 1 error C2223: left of '->GetStringUTFChars' must point to struct/union
Error 2 error C2223: left of '->ReleaseStringUTFChars' must point to struct/union
Error 5 error C2223: left of '->NewStringUTF' must point to struct/union
On "char outCStr[128];" :
Error 3 error C2143: syntax error : missing ';' before 'type'
Error 4 error C2065: 'outCStr' : undeclared identifier
Do anyone know how to fix these ? Thanks in advance