🚀 Kick-start your C++! A template for modern C++ projects using CMake, CI, code coverage, clang-format, reproducible dependency management and much more.
Say I write the following simple function at include/greeter/greeter.h, and then I call it in the main function in standalone/source/main.cpp.
#include <map>
void testfunc() {
std::map<int,int> m;
m.at(1);
}
Apparently, there will be no-key error.
However, running the standalone doesn't reveal any clue about where the error is.
It only says:
$ ./build/standalone/DST
libc++abi: terminating due to uncaught exception of type std::out_of_range: map::at: key not found
[1] 81303 abort ./build/standalone/Greeter
This is quite a pain in development, as the user has no clue about the location of the mistake.
Is there a way to print the call stack or the line number where the error originally happens?
Say I write the following simple function at
include/greeter/greeter.h
, and then I call it in the main function instandalone/source/main.cpp
.Apparently, there will be no-key error. However, running the standalone doesn't reveal any clue about where the error is. It only says:
This is quite a pain in development, as the user has no clue about the location of the mistake. Is there a way to print the call stack or the line number where the error originally happens?