Provide a way to selectively enable assertions in release mode

- Throwing an assertion exception for proper stack unwinding, making
  sure destructors are called

- On in Debug mode, in Release, enable via:

      cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_ASSERTIONS=ON

Current problem that I'm seeing is that some code is not catching
exceptions or worse silently swallowing them. Would like to check the
whole pipeline before merging this in.
This commit is contained in:
Daniel J. Hofmann
2016-01-20 12:41:33 +01:00
committed by Patrick Niklaus
parent 17f8e65808
commit 502aedb33e
3 changed files with 56 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
#ifndef OSRM_ASSERT_HPP
#define OSRM_ASSERT_HPP
#include <boost/assert.hpp>
#include <stdexcept>
namespace osrm
{
namespace util
{
// Assertion type to be thrown for stack unwinding
struct assertionError final : std::logic_error
{
assertionError(const char *msg) : std::logic_error{msg} {}
};
}
}
#endif