47 lines
2.3 KiB
C
47 lines
2.3 KiB
C
#ifndef UTILS_H
|
|
#define UTILS_H
|
|
|
|
#include <stddef.h>
|
|
#define ASSERT_EXHAUSTIVE_MATCH() \
|
|
(fprintf( \
|
|
stderr, \
|
|
"unexhaustive match at %s:%d in %s()\n", \
|
|
__FILE__, \
|
|
__LINE__, \
|
|
__func__ \
|
|
), \
|
|
exit(1))
|
|
|
|
#define TODO() \
|
|
(fprintf( \
|
|
stderr, \
|
|
"unimplemented branch at %s:%d in %s()\n", \
|
|
__FILE__, \
|
|
__LINE__, \
|
|
__func__ \
|
|
), \
|
|
exit(1))
|
|
|
|
#define ASSERT(condition, message) \
|
|
if (!condition) \
|
|
(fprintf( \
|
|
stderr, \
|
|
"failed assertion: \"%s\" at %s:%d in %s()", \
|
|
message, \
|
|
__FILE__, \
|
|
__LINE__, \
|
|
__func__ \
|
|
), \
|
|
exit(1))
|
|
|
|
char* alloc_cstring(const char* source);
|
|
|
|
typedef struct {
|
|
char* value;
|
|
size_t length;
|
|
} AllocatedString;
|
|
|
|
AllocatedString alloc_string(const char* source, size_t length);
|
|
|
|
#endif
|