需要建议来尝试构建此应用程序(运行 出现 2 个错误)
Need advice trying to get this app to build (running into 2 errors)
我正在尝试将 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' 对象的默认初始化(又名 'const unsigned long')] --> 这是 Android Studio 中“bytes_to_write”行的 related/highlighted。
也出现在下方仍然与另一个“bytes_to_write”行相关 [C:\Users\Desktop\dolphin\Source\Core\DiscIO\WIABlob.cpp:1488:25: error: default initialization of an object of const type 'const u64' (aka '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(现在已经坚持了几个星期)
你的错误信息应该很清楚了。相关部分:
../../../../../../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
,这是不允许的(想想 return 类型会是什么)。您需要将一个参数转换为另一种类型,或者您可以明确说明您想要哪个版本的 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);
我正在尝试将 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' 对象的默认初始化(又名 'const unsigned long')] --> 这是 Android Studio 中“bytes_to_write”行的 related/highlighted。 也出现在下方仍然与另一个“bytes_to_write”行相关 [C:\Users\Desktop\dolphin\Source\Core\DiscIO\WIABlob.cpp:1488:25: error: default initialization of an object of const type 'const u64' (aka '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(现在已经坚持了几个星期)
你的错误信息应该很清楚了。相关部分:
../../../../../../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
,这是不允许的(想想 return 类型会是什么)。您需要将一个参数转换为另一种类型,或者您可以明确说明您想要哪个版本的 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);