LehrFEM++ 1.0.0
A simple Finite Element Library for teaching
Loading...
Searching...
No Matches
lf_assert.cc
1
3#include "lf_assert.h"
4
5#include <boost/stacktrace.hpp>
6#include <iostream>
7
8namespace lf::base {
9
10// Output for assertions
11// NOLINTNEXTLINE(misc-no-recursion)
12void AssertionFailed(const std::string& expr, const std::string& file,
13 long line, const std::string& msg) {
14 std::cerr << "***** Internal Program Error - assertion (" << expr
15 << ") failed:\n"
16 << file << '(' << line << "): " << msg << std::endl; // NOLINT
17 std::cerr << "Backtrace:\n" << boost::stacktrace::stacktrace() << '\n';
18 std::abort();
19}
20
21} // end namespace lf::base
22
23#ifdef LF_REDIRECT_ASSERTS
24namespace boost {
25// the following is needed to redirect BOOST_ASSERT(_MSG)/BOOST_VERIFY (_MSG)
26// NOLINTNEXTLINE(misc-no-recursion)
27void assertion_failed_msg(char const* expr, char const* msg,
28 char const* /*function*/, char const* file,
29 long line) {
30 lf::base::AssertionFailed(expr, file, line, msg); // NOLINT
31}
32
33void assertion_failed(char const* expr, char const* /*function*/,
34 char const* file, long line) {
35 lf::base::AssertionFailed(expr, file, line, "");
36}
37} // namespace boost
38#endif
Contains basic functionality that is used by other parts of LehrFEM++.
Definition base.h:15
void AssertionFailed(const std::string &expr, const std::string &file, long line, const std::string &msg)
Definition lf_assert.cc:12