#ifndef UTILS_H #define UTILS_H #include #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