error: array type 'va_list' (aka '__builtin_va_list') is not assignable

error: array type 'va_list' (aka '__builtin_va_list') is not assignable

我应该怎么做才能使其可分配?我已经从头文件中的这个函数自动生成了 JNI 函数。这是头文件中的函数声明 *

char* stringFormatV(const char* format, va_list args);

    SWIGEXPORT jstring JNICALL Java_jnisourceJNI_stringFormatV(JNIEnv
        *jenv, jclass jcls, jstring jarg1, jlong jarg2) {
              jstring jresult = 0 ;
              char *arg1 = (char *) 0 ;
              va_list arg2 ;
              va_list *argp2 ;
              char *result = 0 ;

              (void)jenv;
              (void)jcls;
              arg1 = 0;
              if (jarg1) {
                arg1 = (char *)(*jenv)->GetStringUTFChars(jenv, jarg1, 0);
                if (!arg1) return 0;
              }
              argp2 = *(va_list **)&jarg2; 
              if (!argp2) {
                SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null va_list");
                return 0;
              }
              arg2 = *argp2; //here is the problem
              result = (char *)stringFormatV((char const *)arg1,arg2);
              if (result) jresult = (*jenv)->NewStringUTF(jenv, (const char *)result);
              if (arg1) (*jenv)->ReleaseStringUTFChars(jenv, jarg1, (const char *)arg1);
              return jresult;
            }

在这一行编译器给出错误

arg2 = *argp2; //here is the problem

您可能想要read the variable length argument documentation. Especially the section about wrapping va_list其中指出

As far as we know, there is no obvious way to wrap these functions with SWIG.

总之,这不太可能。

我能看到的唯一解决方案是提供一个可变参数函数,SWIG 为其生成一个函数,这个可变参数函数调用真正的 stringFormatV 函数。