Issue
I have this code:
#include <stacktrace>
#include <iostream>
int nested_func(int c)
{
std::cout << std::stacktrace::current() << '\n';
return c + 1;
}
int func(int b)
{
return nested_func(b + 1);
}
int main()
{
std::cout << func(777);
}
I install gcc-12 and gcc-13 by following on ubuntu22.04
sudo apt install gcc-13 g++-13
sudo apt install gcc-12 g++-12
Then I try to compile the code:
g++-13 -std=c++23 -lstdc++_libbacktrace test.cpp
Yet I get following error for both gcc-12 and gcc-13
test.cpp: In function ‘int nested_func(int)’:
test.cpp:6:23: error: ‘std::stacktrace’ has not been declared
6 | std::cout << std::stacktrace::current() << '\n';
|
Solution
As in the comments, this is probably because your distribution does not fully support c++23 yet. Thus, the _GLIBCXX_HAVE_STACKTRACE
checked in the header <stacktrace>
is not set.
Answered By - Yonathan Ashebir Answer Checked By - Marilyn (WPSolving Volunteer)