我的项目在 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/