c++ - 没有匹配函数调用‘std::exception::exception(<brace-enclosed initializer list>)

标签 c++ ubuntu linux-mint

我的项目在 Windows (vc++17) 上构建,我是 Linux 构建的新手,所以我不确定发生了什么。
我为我的项目创建了 CMakeLists 文件(需要 C++17),生成了 makefile,然后我使用了 make尝试在 Linux 上构建它。错误是:

/home/julien/source/zipfs/zipfs/include/zipfs/zipfs_assert.h:30:70: error: no matching function for call to ‘std::exception::exception(<brace-enclosed initializer list>)’
   30 |   zipfs_usage_error_t(const char* message) : std::exception{ message } {}
      |                                                                      ^
In file included from /usr/include/c++/9/exception:38,
                 from /usr/include/c++/9/new:40,
                 from /usr/include/c++/9/ext/new_allocator.h:33,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/c++allocator.h:33,
                 from /usr/include/c++/9/bits/allocator.h:46,
                 from /usr/include/c++/9/string:41,
                 from /home/julien/source/zipfs/zipfs/include/zipfs/zipfs_path_t.h:3,
                 from /home/julien/source/zipfs/zipfs/include/zipfs/zipfs_error_t.h:3,
                 from /home/julien/source/zipfs/zipfs/source/zipfs_error_t.cpp:1:
涉案代码为:
zipfs_usage_error_t(const char* message) : std::exception{ message } {}
我看不出这有什么问题;是 c++ 版本不匹配吗?

最佳答案

std::exception does not provide a constructor接受 const char*范围。
如果您正在使用的 Windows 标准库中存在一个,则它是该语言的不可移植扩展。
many derived classes可以将其用作您的基类,它确实支持此构造函数。

关于c++ - 没有匹配函数调用‘std::exception::exception(<brace-enclosed initializer list>),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71767599/

相关文章:

c++ - 使用派生类的数据成员初始化基类

ubuntu - 同一个libc有什么不同? 1.2 1.3 1.4 等

linux - Shell脚本练习环境。

c++ - 搜索存储在树中的数据

c++ - 访问由 C++ 中的局部声明隐藏的封闭范围(非全局)中的变量?

c++ - 如何将此代码从递归更改为迭代

ubuntu - Zookeeper 服务器启动/服务器连接问题

python - 与 windows 相比,ubuntu 中 python 程序的运行时间非常小。为什么?

linux - 如何在 Linux Mint 12 上更改 GNOME3 面板填充?

java - 保存 .java 文件时出现权限错误