I have been using the Boost stacktrace library to print out a stacktrace of my program.
When compiling with pure C++ it compiles and my program prints the stacktrace nicely. However when compiling with C++ /CLI, my program doesn't print the stacktrace.
Here is my reproducable example :
#include <boost/stacktrace.hpp>
#include <sstream>
#include <iostream>
#include <string>
int main() {
std::stringstream stack;
stack << boost::stacktrace::stacktrace();
std::string stacktrace = stack.str(); // The string "stacktrace" is empty when running with C++ CLI
std::cout << stacktrace;
}
Compiling this with C++ /CLI doesn't print the stacktrace to stdout, whereas compiling with pure C++ does print it to stdout.
Another thing is that when I use boost/stacktrace/stacktrace.hpp
instead of boost/stacktrace.hpp
my program fails to print the stacktrace even in pure C++.
Unfortunately, I couldn't find any references to this issue on stack overflow.
I am on Windows, and I'm using Visual Studio 2022.
I am using Boost version Version: 1.78.0.
I installed boost with vcpkg.
Thank you
I don't think Boost Stacktrace claims CLR support.
I'd expect some output, but not particularly useful output.
Of course, in CLR mode, you can use .NET stacktraces: https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.stacktrace?view=net-6.0
Another thing is that when I use boost/stacktrace/stacktrace.hpp instead of boost/stacktrace.hpp my program fails to print the stacktrace even in pure C++.
That's probably because that's not correct usage. There's many nuts and bolts to configuring the library correctly, see https://www.boost.org/doc/libs/1_79_0/doc/html/stacktrace/configuration_and_build.html. One of the possible configurations leads to no-op implementation.