我正在使用 #include
#include <fmt/ranges.h>
#include <array>
int main()
{
std::array<short unsigned int, 3> arr = {1, 2, 3};
fmt::print("{}", arr);
}
它在 Windows 和 Macos 中可以正确编译,但在使用 g++ 编译器的 Linux 中失败,并出现以下错误:
../externals/fmtlib/fmt/ranges.h:49:29:错误:类“fmt::v10::detail::is_std_string_like”中的所有成员函数都是私有的 [-Werror=ctor-dtor-privacy] 模板类 is_std_string_like {
../externals/fmtlib/fmt/ranges.h:65:29:错误:类“fmt::v10::detail::is_map”中的所有成员函数都是私有的[-Werror=ctor-dtor-privacy]
模板类 is_map {
../externals/fmtlib/fmt/ranges.h:49:29:错误:类“fmt::v10::detail::is_std_string_like”中的所有成员函数都是私有的 [-Werror=ctor-dtor-privacy] 模板类 is_std_string_like {
../externals/fmtlib/fmt/ranges.h:65:29:错误:类“fmt::v10::detail::is_map”中的所有成员函数都是私有的[-Werror=ctor-dtor-privacy]
模板类 is_map {
截至撰写本文时,MSVC 和 Clang 是仅有的 2 个支持该标头的编译器。 g++不支持吗
看来 MSVC 和 Clang 是唯一支持此标头的 2 个编译器
请帮助我。
问题是您选择的
-Werror=ctor-dtor-privacy
会拒绝有效的 C++ 代码,解决方案是从构建标志中删除此标志,至少在编译 fmt/ranges.h
时如此。