test.c的jni compile cpp和c有什麼區別?
#include <string.h>
#include <jni.h>
#include <android/log.h>
#include <stdio.h>
#include <stdlib.h>
jstring Java_com_test_b_hello_hellostr(JNIEnv* env,jobject thiz)
{
return (*env)->NewStringUTF(env, "Hello from JNI !");
}
這編譯OK。但是,當我更改爲test.cpp時,編譯出現錯誤。
libb/jtest.cpp:在函數 '_jstring * Java_com_test_b_hello_hellostr(JNIEnv的*,_jobject *)': jtest.cpp:108:錯誤:基地操作數 ' - >' 具有非指針類型 '_JNIEnv' make [1]:* [out /.../obj/ SHARED_LIBRARIES/libdrvb_intermediates/jtest.o] Error 1
這是爲什麼?它有不同的應用程序和C?
我檢查系統jni.h文件:alps\dalvik\libnativehelper\include\nativehelper\jni.h
。
.
void (*ReleaseStringChars)(JNIEnv*, jstring, const jchar*);
jstring (*NewStringUTF)(JNIEnv*, const char*);
jsize (*GetStringUTFLength)(JNIEnv*, jstring);
...
jstring NewStringUTF(const char* bytes)
{ return functions->NewStringUTF(this, bytes); }
.....