ciabatta/inc/assert.h

25 lines
717 B
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
2022-06-16 12:36:35 +00:00
void _Noreturn _assert(
char const *cond,
char const *func,
char const *file,
2022-06-16 12:36:35 +00:00
int 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)) { \
2022-06-16 12:36:35 +00:00
_assert(#condition, __func__, __FILE__, __LINE__); \
2022-06-02 05:18:26 +00:00
} \
} while(0)
#endif