kakoune/src/assert.hh

35 lines
599 B
C++
Raw Normal View History

2011-09-09 21:24:18 +02:00
#ifndef assert_hh_INCLUDED
#define assert_hh_INCLUDED
#include "exception.hh"
namespace Kakoune
{
struct assert_failed : logic_error
{
assert_failed(const String& message);
2012-09-04 00:17:41 +02:00
String description() const override;
2011-09-09 21:24:18 +02:00
private:
String m_message;
2011-09-09 21:24:18 +02:00
};
void on_assert_failed(const String& message);
2011-09-09 21:24:18 +02:00
}
#define STRINGIFY(X) #X
#define TOSTRING(X) STRINGIFY(X)
#define COMMA ,
2011-09-09 21:24:18 +02:00
#ifdef assert
#undef assert
#endif
#define assert(condition) \
if (not (condition)) \
on_assert_failed("assert failed \"" #condition "\" at " __FILE__ ":" TOSTRING(__LINE__))
2011-09-09 21:24:18 +02:00
#endif // assert_hh_INCLUDED