我刚开始使用JNI,所以我尝试用C语言从本地库中获取一个double和一个unsigned int,并将这些值返回给我的Java端,但我一直从Android Studio得到以下错误
Error:(111, 37) error: called object type 'double' is not a function or function pointer
Error:(117, 43) error: called object type 'unsigned int' is not a function or function pointer
Error:(220, 19) error: functions that differ only in their return type cannot be overloaded下面是我的代码:
double SuperpoweredExample::getPosition() {
double pos = playerA->positionMs();
return pos;
}
unsigned int SuperpoweredExample::getDuration() {
unsigned int dur = playerA->durationMs();
return dur;
}虽然这是Extern C结构
JNIEXPORT jdouble Java_com_superpowered_crossexample_MainActivity_getPosition(JNIEnv *javaEnvironment, jobject self) {
return example->getPosition();
}
JNIEXPORT jint Java_com_superpowered_crossexample_MainActivity_getDuration(JNIEnv *javaEnvironment, jobject self) {
return example->getDuration();
}伙计们,我会非常感谢你们的帮助……提前谢谢你
发布于 2017-06-29 20:34:59
您并没有费心去提供完整的类定义,或者回答评论中提出的问题,但是看起来
playerA->positionMs是数据成员,而不是成员方法,对于其他方法调用也是如此。所以你不能把它们作为方法来调用。但是您可以直接将它们作为值返回。
https://stackoverflow.com/questions/44789314
复制相似问题