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); }
.....