error: base operand of ‘->’ has non-pointer type ‘JNIEnv’

后端 未结 2 1043
面向向阳花
面向向阳花 2020-12-29 03:53
#include 
#include 

 JNIEnv* create_vm() {
    JavaVM* jvm;
    JNIEnv* env;
    JavaVMInitArgs args;
    JavaVMOption options[1];

             


        
2条回答
  •  旧时难觅i
    2020-12-29 04:50

    I noticed the different ways of implementing in C and C++ but I think I am writing it correctly.

    You are using the C variant, but are compiling with g++, which invokes the C++ compiler (even if your source file has a .c extension).

    Either change the C variants like

    (*env)->FindClass(env, ...)
    

    to the C++ variants, like

    env->FindClass(...)
    

    or switch your compiler to gcc to compile the source as C code.

提交回复
热议问题