从https://github.com/gcc-mirror/gcc/commit/3acb929cc0beb79e6f4005eb22ee88b45e1cbc1d提交,C++标准头
<stacktrace>
存在诸如std::stacktrace_entry
之类的东西,但没有声明,因为_GLIBCXX_HAVE_STACKTRACE
未定义都不是。
我已经在 https://godbolt.org/z/b9TvEMYnh 上尝试过这个,但是一旦我添加了参数,就会发出链接器错误
-lstd++_libbacktrace
(ofc,未找到)
#include <stacktrace> // header found
int main() {
// can't use features like 'std::stacktrace_entry' and 'std::stacktrace'
}
从提交描述来看,这条消息意味着什么? :
目前,只有使用 --enable-libstdcxx-backtrace=yes 时才会构建新库。
从源代码构建 GCC 的一部分是运行
configure
shell 脚本并向其传递一堆参数来告诉它如何行为。 该提交消息告诉您,为了启用此功能,您必须添加以下配置参数:
--enable-libstdcxx-backtrace=yes
根据https://en.cppreference.com/w/cpp/compiler_support/23 gcc-14 支持 stacktrace,带有 *,如果将光标悬停在 * 上,则显示它必须与 -lstdc++exp 链接。 这对我有用,我在其他地方没有看到这个建议。