需要建议尝试构建此应用程序(遇到 2 个错误)
Posted
技术标签:
【中文标题】需要建议尝试构建此应用程序(遇到 2 个错误)【英文标题】:Need advice trying to get this app to build (running into 2 errors) 【发布时间】:2021-01-12 09:04:42 【问题描述】:我正在尝试将 Dolphin 模拟器中的一项功能实现到非官方版本中,同时自己学习 C++ 编码。现在我能够减少一个文件的错误数量,但这些是我得到的错误。
第一个代码错误是针对这个的:
const u64 bytes_per_chunk = std::min(out_data_per_chunk, VolumeWii::GROUP_DATA_SIZE);
const u64 total_size = blocks_in_this_group * VolumeWii::BLOCK_DATA_SIZE;
const u64 data_offset = parameters.data_offset + write_offset_of_group;
在引用“ std::min " 它也出现在这里:
const u64 bytes_to_write = std::min(bytes_to_write_total, VolumeWii::GROUP_DATA_SIZE);
错误 = (C:\Users\Desktop\dolphin\Source\Core\DiscIO\WIABlob.cpp:1488:42: 错误:没有匹配的函数调用 'min')
------------------------------------------ ----------------------------------
我得到的下一个错误(所有这些都在同一个 .cpp 文件中)也来自相同的代码行:
const u64 bytes_per_chunk = std::min(out_data_per_chunk, VolumeWii::GROUP_DATA_SIZE);
const u64 total_size = blocks_in_this_group * VolumeWii::BLOCK_DATA_SIZE;
const u64 data_offset = parameters.data_offset + write_offset_of_group;
这里也是:
const u64 bytes_to_write = std::min(bytes_to_write_total, VolumeWii::GROUP_DATA_SIZE);
我得到的后一组错误是 [C:\Users\Desktop\dolphin\Source\Core\DiscIO\WIABlob.cpp:1465:21: 错误:默认初始化 const 类型 'const u64' 的对象(aka 'const unsigned long')] --> 这与 android Studio 中的“bytes_to_write”行相关/突出显示。 也出现在下方仍然与另一个“bytes_to_write”行相关 [C:\Users\Desktop\dolphin\Source\Core\DiscIO\WIABlob.cpp:1488:25: 错误:const 类型的对象的默认初始化 'const u64' (又名'const unsigned long')]
到目前为止,这些是阻止我构建应用程序的 2 个错误。
============================================= ========
构建错误:
In file included from ../../../../../../Core/DiscIO/WIABlob.cpp:5:
In file included from ../../../../../../Core\DiscIO/WIABlob.h:21:
In file included from ../../../../../../Core\DiscIO/WiiEncryptionCache.h:12:
../../../../../../Core\DiscIO/VolumeWii.h:91:3: warning: 'DiscIO::VolumeWii::CheckBlockIntegrity' hides overloaded virtual function [-Woverloaded-virtual]
CheckBlockIntegrity(u64 block_index, const Partition &partition, const Partition partition1) const ;
^
../../../../../../Core\DiscIO/Volume.h:112:16: note: hidden overloaded virtual function 'DiscIO::Volume::CheckBlockIntegrity' declared here: different number of parameters (2 vs 3)
virtual bool CheckBlockIntegrity(u64 block_index, const Partition& partition) const
^
In file included from ../../../../../../Core/DiscIO/WIABlob.cpp:5:
In file included from ../../../../../../Core\DiscIO/WIABlob.h:21:
In file included from ../../../../../../Core\DiscIO/WiiEncryptionCache.h:12:
../../../../../../Core\DiscIO/VolumeWii.h:141:10: warning: 'DiscIO::VolumeWii::CheckBlockIntegrity' hides overloaded virtual function [-Woverloaded-virtual]
bool CheckBlockIntegrity(u64 block_index, const std::vector<u8> &encrypted_data,
^
../../../../../../Core\DiscIO/Volume.h:112:16: note: hidden overloaded virtual function 'DiscIO::Volume::CheckBlockIntegrity' declared here: different number of parameters (2 vs 3)
virtual bool CheckBlockIntegrity(u64 block_index, const Partition& partition) const
^
../../../../../../Core/DiscIO/WIABlob.cpp:1465:39: error: no matching function for call to 'min'
const u64 bytes_per_chunk = std::min(out_data_per_chunk, VolumeWii::GROUP_DATA_SIZE);
^~~~~~~~
C:/Android/SDK/ndk/21.3.6528147/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/c++/v1\algorithm:2532:1: note: candidate template ignored: deduced conflicting types for parameter '_Tp' ('unsigned long' vs. 'unsigned int')
min(const _Tp& __a, const _Tp& __b)
^
C:/Android/SDK/ndk/21.3.6528147/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/c++/v1\algorithm:2543:1: note: candidate template ignored: could not match 'initializer_list<type-parameter-0-0>' against 'unsigned long'
min(initializer_list<_Tp> __t, _Compare __comp)
^
C:/Android/SDK/ndk/21.3.6528147/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/c++/v1\algorithm:2523:1: note: candidate function template not viable: requires 3 arguments, but 2 were provided
min(const _Tp& __a, const _Tp& __b, _Compare __comp)
^
C:/Android/SDK/ndk/21.3.6528147/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/c++/v1\algorithm:2552:1: note: candidate function template not viable: requires single argument '__t', but 2 arguments were provided
min(initializer_list<_Tp> __t)
^
../../../../../../Core/DiscIO/WIABlob.cpp:1488:42: error: no matching function for call to 'min'
const u64 bytes_to_write = std::min(bytes_to_write_total, VolumeWii::GROUP_DATA_SIZE);
^~~~~~~~
C:/Android/SDK/ndk/21.3.6528147/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/c++/v1\algorithm:2532:1: note: candidate template ignored: deduced conflicting types for parameter '_Tp' ('unsigned long' vs. 'unsigned int')
min(const _Tp& __a, const _Tp& __b)
^
C:/Android/SDK/ndk/21.3.6528147/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/c++/v1\algorithm:2543:1: note: candidate template ignored: could not match 'initializer_list<type-parameter-0-0>' against 'unsigned long'
min(initializer_list<_Tp> __t, _Compare __comp)
^
C:/Android/SDK/ndk/21.3.6528147/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/c++/v1\algorithm:2523:1: note: candidate function template not viable: requires 3 arguments, but 2 were provided
min(const _Tp& __a, const _Tp& __b, _Compare __comp)
^
C:/Android/SDK/ndk/21.3.6528147/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/c++/v1\algorithm:2552:1: note: candidate function template not viable: requires single argument '__t', but 2 arguments were provided
min(initializer_list<_Tp> __t)
^
如果您想从此处的 .cpp 文件中查看我正在使用的原始代码: https://github.com/JosJuice/dolphin/blob/660d81a10b4a8ff9a61631e69fb93e9010bccbc0/Source/Core/DiscIO/WIABlob.cpp
我希望我能得到任何好的建议来解决这个问题并最终构建 Apk(现在卡在这个问题上好几个星期了)
【问题讨论】:
您的确切错误消息是什么?对于std::min
,它可能列出了您传递的精确类型,我猜它们是不同的类型。请确保您编辑您的问题并将错误包含在文本中。
感谢您的建议;我已编辑问题以包含 Android Studio 中提供给我的错误行。
发布您的代码而不是图片。并且你包括#include <algorithm>
@DrowningArtist - 请将任何构建错误直接放在问题中,而不是作为外部链接。而且我们不需要完整的构建日志,只需要完整的错误消息。
@0x476f72616e 是的,我确实有“#include ”,并且我还删除了图片。
【参考方案1】:
您的错误信息应该很清楚。相关部分:
../../../../../../Core/DiscIO/WIABlob.cpp:1465:39: error: no matching function for call to 'min'
const u64 bytes_per_chunk = std::min(out_data_per_chunk, VolumeWii::GROUP_DATA_SIZE);
^~~~~~~~
C:/Android/SDK/ndk/21.3.6528147/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/c++/v1\algorithm:2532:1: note: candidate template ignored: deduced conflicting types for parameter '_Tp' ('unsigned long' vs. 'unsigned int')
min(const _Tp& __a, const _Tp& __b)
关键部分是您将不同的类型传递给std::min
,这是不允许的(想想返回类型是什么)。您需要将其中一个参数转换为另一种类型,或者您可以明确说明您想要哪个版本的 std::min
。
转换如下所示:
const u64 bytes_per_chunk = std::min(out_data_per_chunk, static_cast<unsigned long>(VolumeWii::GROUP_DATA_SIZE));
显式调用版本如下所示:
const u64 bytes_per_chunk = std::min<u64>(out_data_per_chunk, VolumeWii::GROUP_DATA_SIZE);
【讨论】:
非常感谢您的建议;我能够构建它,现在我正在对其进行测试。它能够构建并发出 6 个警告,但我希望事情仍然可以解决。 只是提供更新,因为您给了我构建 apk 的答案。虽然它是构建的,但该功能仍然不起作用,但我会考虑尝试让它与你给我的建议一起工作。因此再次感谢。以上是关于需要建议尝试构建此应用程序(遇到 2 个错误)的主要内容,如果未能解决你的问题,请参考以下文章
React Native Project 错误:ld:找不到框架 GoogleAdMob