diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2025-04-24 18:37:11 -0400 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2025-04-24 18:37:11 -0400 |
| commit | 072f0c594526d96dac1c181d057eb9cf5d16862d (patch) | |
| tree | f085f52fdbbced413f9e510e3ca4174a84be251f | |
| parent | 48bc192d262416e9466922c4b65b066ee6027d9a (diff) | |
| download | volute-072f0c594526d96dac1c181d057eb9cf5d16862d.zip | |
eprintf
| -rw-r--r-- | Makefile | 4 | ||||
| -rw-r--r-- | eprintf.c | 27 | ||||
| -rw-r--r-- | eprintf.h | 2 |
3 files changed, 31 insertions, 2 deletions
@@ -1,9 +1,9 @@ CFLAGS = -std=c99 -Wall -Wextra -pedantic -Wno-deprecated-declarations -D_XOPEN_SOURCE=700L LDFLAGS = -lSDL2 -lSDL2_ttf -lm -SRC = main.c microui.c renderer.c widget.c ui.c unit.c engine.c compressor.c +SRC = main.c microui.c renderer.c widget.c ui.c unit.c engine.c compressor.c eprintf.c OBJ = ${SRC:.c=.o} -HDR = microui.h renderer.h widget.h ui.h unit.h engine.h +HDR = microui.h renderer.h widget.h ui.h unit.h engine.h eprintf.h util.h TEST_SRC = test.c test_angular_speed.c test_fraction.c test_pressure.c test_temperature.c test_volume.c test_volume_flow_rate.c test_mass_flow_rate.c test_engine.c unit.c engine.c TEST_OBJ = ${TEST_SRC:.c=.o} diff --git a/eprintf.c b/eprintf.c new file mode 100644 index 0000000..386293b --- /dev/null +++ b/eprintf.c @@ -0,0 +1,27 @@ +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> + +#include "eprintf.h" + +void +eprintf(const char *fmt, ...) { + va_list args; + + va_start(args, fmt); + fprintf(stderr, "error: "); + vfprintf(stderr, fmt, args); + fprintf(stderr, "\n"); + va_end(args); + exit(1); +} + +void weprintf(const char *fmt, ...) { + va_list args; + + va_start(args, fmt); + fprintf(stderr, "warning: "); + vfprintf(stderr, fmt, args); + fprintf(stderr, "\n"); + va_end(args); +} diff --git a/eprintf.h b/eprintf.h new file mode 100644 index 0000000..224b852 --- /dev/null +++ b/eprintf.h @@ -0,0 +1,2 @@ +void eprintf(const char *fmt, ...); +void weprintf(const char *fmt, ...); |