In my Main.cpp file, I have a JNI call:
JNIEXPORT jstring JNICALL
Java_packagename_MainActivity_GenerateAlphabet(JNIEnv *env, jobject thiz)
{
generateAlphabet([](string letters, string numbers) {
return (env)->NewStringUTF("test");
});
}
but this code gives me an error:
jni / Main.cpp: lambda function:
jni / Main.cpp: 86: 33: error: 'env' not writing
I really need to use env in lambda function, can anyone help me.
EDIT:
The accepted answer solves the problem, but keep in mind that you cannot return the value inside the lambda expression.
Grace source
share