所以我一直在调查JNI调用,所以我可以与一些预先编写的C程序进行交互,我不知道任何C,但我正在尝试学习一些基础知识.我刚刚尝试对JNI方法之外的方法进行简单调用,但始终收到以下错误
错误c3861’myMethod’:找不到标识符
#include <stdio.h>
#include <string.h>
#include "StringFuncs.h"
JNIEXPORT jstring JNICALL Java_StringFuncs_changeWord(JNIEnv *env, jobject obj, jstring inStr, jint inLen)
{
const char *inString;
inString = env->GetStringUTFChars(inStr, NULL);
char otherString[40];
strcpy_s(otherString,inString);
if(myMethod())
{
memset(otherString, '-', inLen);
}
jstring newString = env->NewStringUTF((const char*)otherString);
return newString;
}
bool myMethod()
{
return true;
}
int main()
{
return 0;
}
智慧的任何话语?
您必须在调用方法之前声明方法.所以在你的标题类型bool myMethod();
或者您可以将代码移到_changeWord函数上方,然后声明/定义就在其中.
