1#ifndef LIBCLOD_CLOD_DEBUG_H
2#define LIBCLOD_CLOD_DEBUG_H
5#include <clod/stream.h>
7#include <clod/sys/sys.h>
9static inline int debug_print(
33 buff.
ptr[buff.
len++] =
'\n';
35 clod_stderr->write(clod_stderr, &buff);
40#define _debug_assume(expr) ((expr) ? (void)0 : __builtin_unreachable())
41#elif defined(_MSC_VER)
42#define _debug_assume(expr) __assume(expr)
47#define debug(context, msg, ...) (!(context) ? (void)0 : (debug_print(#context, __FILE__, __LINE__, __func__, msg __VA_OPT__(,) __VA_ARGS__), (void)0))
48#define fatal(context, msg, ...) (!(context) ? (void)0 : (debug_print(#context, __FILE__, __LINE__, __func__, msg __VA_OPT__(,) __VA_ARGS__), clod_exit(1), _debug_assume(0)))
49#define assert_fatal(context, expr, msg, ...) (!(context) ? _debug_assume(expr) : (expr) ? (void)0 : (debug_print(#context, __FILE__, __LINE__, __func__, "Assertion \""#expr"\" failed: "msg __VA_OPT__(,) __VA_ARGS__), clod_exit(1), _debug_assume(0)))
#define CLOD_STRING_C(cstr)
String literal constant.
size_t clod_string_cat(struct clod_string *dst, struct clod_string src)
CLOD_API size_t clod_string_put_uint(struct clod_string *dst, uintmax_t val, struct clod_string alphabet, unsigned char base, unsigned char min_digits, unsigned char max_digits)
struct clod_string clod_string_from_cstr(const char *cstr)
Make a string from a C string.
#define CLOD_STRING_NEW(size)
Create a new empty string with the given capacity on the stack.