2011-09-09 23:24:18 +04:00
|
|
|
#ifndef assert_hh_INCLUDED
|
|
|
|
#define assert_hh_INCLUDED
|
|
|
|
|
|
|
|
namespace Kakoune
|
|
|
|
{
|
|
|
|
|
2016-03-01 01:15:36 +03:00
|
|
|
class StringView;
|
2015-05-29 15:35:09 +03:00
|
|
|
|
|
|
|
// return true if user asked to ignore the error
|
2016-03-01 01:15:36 +03:00
|
|
|
bool notify_fatal_error(StringView message);
|
2015-05-29 15:35:09 +03:00
|
|
|
|
2012-10-17 19:01:08 +04:00
|
|
|
void on_assert_failed(const char* message);
|
2012-10-16 18:16:32 +04:00
|
|
|
|
2011-09-09 23:24:18 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#define STRINGIFY(X) #X
|
|
|
|
#define TOSTRING(X) STRINGIFY(X)
|
|
|
|
|
2013-02-27 22:02:01 +04:00
|
|
|
#ifdef KAK_DEBUG
|
2017-02-19 17:37:32 +03:00
|
|
|
#define kak_assert(...) do { \
|
2016-05-17 21:39:55 +03:00
|
|
|
if (not (__VA_ARGS__)) \
|
|
|
|
on_assert_failed("assert failed \"" #__VA_ARGS__ \
|
2017-02-19 17:37:32 +03:00
|
|
|
"\" at " __FILE__ ":" TOSTRING(__LINE__)); \
|
|
|
|
} while (0)
|
2013-02-27 22:02:01 +04:00
|
|
|
#else
|
2017-02-19 17:37:32 +03:00
|
|
|
#define kak_assert(...) do {} while (0)
|
2013-02-27 22:02:01 +04:00
|
|
|
#endif
|
|
|
|
|
2011-09-09 23:24:18 +04:00
|
|
|
|
|
|
|
#endif // assert_hh_INCLUDED
|