How to use <stacktrace> in GCC trunk?
Asked Answered
R

1

4

From https://github.com/gcc-mirror/gcc/commit/3acb929cc0beb79e6f4005eb22ee88b45e1cbc1d commit, C++ standard header <stacktrace> exists things such as std::stacktrace_entry but is not declared since _GLIBCXX_HAVE_STACKTRACE is not defined neither.

I have tried this on https://godbolt.org/z/b9TvEMYnh but linker error is emitted once I have added the argument -lstd++_libbacktrace (ofc, it was not found)

#include <stacktrace> // header found

int main() {
  // can't use features like 'std::stacktrace_entry' and 'std::stacktrace'
}

What does this message mean from the commit description? :

For now, the new library is only built if --enable-libstdcxx-backtrace=yes is used.

Richy answered 19/1, 2022 at 4:25 Comment(3)
This is now fixed on Compiler Explorer - you still need to link against stdc++_backtrace though - godbolt.org/z/We4T8f4q8Nl
@MattGodbolt Unfortunately this seems not to work anymore.Bytom
@MattGodbolt: No it isn't.Euphrasy
A
7

Part of building GCC from source is to run the configure shell script and pass it a bunch of arguments to tell it how to behave. That commit message is telling you that in order to enable this feature, you must add the following configure argument:

--enable-libstdcxx-backtrace=yes
Alfi answered 19/1, 2022 at 4:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.