ciabatta/inc/assert.h

32 lines
1.1 KiB
C
Raw Normal View History

2022-06-02 23:41:48 +00:00
#pragma once
2022-06-11 20:21:57 +00:00
#if !defined(__func__)
#define __func__ __FUNCTION__
#endif
#define _assert_str_(x) #x
#define _assert_str(x) _assert_str_(x)
2022-06-02 05:18:26 +00:00
extern void _assert_error(
char *cond,
char const *func,
char const *file,
char const *line
);
2022-06-02 05:18:26 +00:00
#if defined(NDEBUG)
#define assert(ignore) ((void)0)
#else
#define _static_assert _Static_assert
#define assert(condition) \
do { \
if(!(condition)) { \
_assert_error( \
#condition, \
2022-06-11 20:21:57 +00:00
__func__, \
__FILE__, \
2022-06-11 20:21:57 +00:00
_assert_str(__LINE__)); \
2022-06-02 05:18:26 +00:00
} \
} while(0)
#endif