From: Lukas Krickl Date: Mon, 6 Nov 2023 19:41:22 +0000 (+0100) Subject: Added panic macro X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=50f3eecd3483015d4509cf28e8a68bfe401dccb4;p=ulas%2F.git Added panic macro --- diff --git a/include/ulas.h b/include/ulas.h index 1864a80..10d5e0a 100644 --- a/include/ulas.h +++ b/include/ulas.h @@ -34,6 +34,11 @@ #define ULASERR(...) fprintf(ulaserr, __VA_ARGS__); #define ULASWARN(...) fprintf(ulaserr, __VA_ARGS__); +#define ULASPANIC(...) \ + { \ + fprintf(ulaserr, __VA_ARGS__); \ + exit(-1); \ + } // format macros #define ULAS_FMT(f, fmt) \ @@ -165,7 +170,6 @@ char *ulas_strndup(const char *src, size_t n); */ typedef int (*ulas_tokrule)(int current); - // tokenisze according to pre-defined rules // returns the amount of bytes of line that were // consumed or -1 on error diff --git a/src/preproc.c b/src/preproc.c index b1102f0..6ccc1d8 100644 --- a/src/preproc.c +++ b/src/preproc.c @@ -59,7 +59,7 @@ int ulas_preprocline(struct ulas_preproc *pp, FILE *dst, const char *raw_line, } } - ULASERR("Unknown preprocessor directive: %s\n", line); + ULASPANIC("Unknown preprocessor directive: %s\n", line); return -1; } found: