jni/hellocpp/main.cpp:16:18: error: base operand of '->' has non-pointer type 'JNIEnv {aka _JNIEnv}'

jni/hellocpp/main.cpp:16:18: error: base operand of '->' has non-pointer type 'JNIEnv {aka _JNIEnv}'


android java 调用c++程序时报的错误,


代码的写法是:

jstring
Java_com_example_hellojni_HelloJni_stringFromJNI( JNIEnv* env,
                                                  jobject thiz, jstring str, jint i )
{
    return (*env)->NewStringUTF(env, "Hello from JNI !");
}


错误在于:

(*env)->NewStringUTF(env, "Hello from JNI !");

这一行,这是c的写法,而我的是cpp程序,需要改写成:

env->NewStringUTF( "Hello from JNI !");

你可能感兴趣的:(jni/hellocpp/main.cpp:16:18: error: base operand of '->' has non-pointer type 'JNIEnv {aka _JNIEnv}')