kakoune/src/assert.hh

31 lines
657 B
C++
Raw Normal View History

2011-09-09 21:24:18 +02:00
#ifndef assert_hh_INCLUDED
#define assert_hh_INCLUDED
namespace Kakoune
{
2016-02-29 23:15:36 +01:00
class StringView;
// return true if user asked to ignore the error
2016-02-29 23:15:36 +01:00
bool notify_fatal_error(StringView message);
2012-10-17 17:01:08 +02:00
void on_assert_failed(const char* message);
2011-09-09 21:24:18 +02:00
}
#define STRINGIFY(X) #X
#define TOSTRING(X) STRINGIFY(X)
#ifdef KAK_DEBUG
#define kak_assert(...) do { \
if (not (__VA_ARGS__)) \
on_assert_failed("assert failed \"" #__VA_ARGS__ \
"\" at " __FILE__ ":" TOSTRING(__LINE__)); \
} while (false)
#else
#define kak_assert(...) do { (void)sizeof(__VA_ARGS__); } while(false)
#endif
2011-09-09 21:24:18 +02:00
#endif // assert_hh_INCLUDED