diff options
| author | Riley Beckett <rbeckettvt@gmail.com> | 2026-07-21 22:14:36 -0400 |
|---|---|---|
| committer | Riley Beckett <rbeckettvt@gmail.com> | 2026-07-21 22:14:36 -0400 |
| commit | 2d1c5db52be9cde9e013a724c149d7a84fe057ba (patch) | |
| tree | b613b945ce27e467132c689bd065871652db03f0 /snag/util.h | |
| parent | feef592b397f6ec6b8b848d93b0cea9b9800f955 (diff) | |
add gen.sh and some better logging
Diffstat (limited to 'snag/util.h')
| -rw-r--r-- | snag/util.h | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/snag/util.h b/snag/util.h index 6f23607..fbf9018 100644 --- a/snag/util.h +++ b/snag/util.h @@ -5,8 +5,19 @@ #include <stddef.h> // utility for errors -void eprintf(const char *format, ...) __attribute__((format(printf, 1, 2))); -void error_out(const char *format, ...) __attribute__((format(printf, 1, 2))); // panic, as the kids say +#if DEBUG + #define log(fmt, ...) _log(__LINE__, __FILE__, fmt, ##__VA_ARGS__) + void _log(int line, const char* file, const char* format, ...) __attribute__((format(printf, 3, 4))); + + #define die(fmt, ...) _die(__LINE__, __FILE__, fmt, ##__VA_ARGS__) + void _die(int line, const char* file, const char* format, ...) __attribute__((format(printf, 3, 4))); +#else + #define log(fmt, ...) _log(fmt, ##__VA_ARGS__) + void _log(const char* format, ...) __attribute__((format(printf, 1, 2))); + + #define die(fmt, ...) _die(fmt, ##__VA_ARGS__) + void _die(const char* format, ...) __attribute__((format(printf, 1, 2))); +#endif void* emalloc(size_t size, char* alloc_reason); // string functions |
