android - 为什么IDE显示: parameter type mismatch: array is not assignable

标签 android c android-studio java-native-interface

我正在 Android Studio 中编写一些 JNI 代码,但在 IDE 中一遍又一遍地遇到相同的错误:

parameter type mismatch: array is not assignable

总是有类似的情况,像这样:

void testB(uint8_t buff[4]) {
   //some code
}

void testA() {
    uint8_t buff[4] = { 0, 1, 2, 3 };     
    testB(buff);  //buff is underlined red and says: parameter type mismatch: array is not assignable
}

所以在 testB(buff) 行上 buff 带有红色下划线,并在悬停时显示上述错误

代码编译并运行良好。这是 IDE 中的错误,还是我在这里做错了什么?我可以摆脱这个烦人的错误吗?

更新:我从评论中得到了答案。感谢 Ian Abbott、Lundin 和 juanchopanza! 我会等一会儿有人写出一个全面的答案,如果没有出现,我会在稍后使用这些评论作为基础来回答这个问题并完成。

最佳答案

您忘记了结束 } 后的分号。编译器只是继续执行,并在一段时间后当它感到困惑时报告错误:

void testA() {
    uint8_t buff[4] = { 0, 1, 2, 3 };    // semi-colon here
    testB(buff);
}

关于android - 为什么IDE显示: parameter type mismatch: array is not assignable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35292030/

相关文章:

java - 如何将 jsonobject 解析为两个不同的列表

c - 带字符串和长的 fscanf

c - 从该设备上文件的名称/描述符获取存储设备 block 大小

android-studio - 原因 : error in opening zip file (android-studio)

java - Android 加载全图 Recyclerview Cardview

android - 错误 : Unable to find module with Gradle path ':capacitor-cordova-android-plugins'

c - 重新声明全局变量与局部变量

java - Android Studio IDE fatal error - "Exception in plugin Gradle."

java - 如何为我的整个应用程序设置默认手机字体

java - 在 Android Studio 上调试