diff options
author | Marvin Borner | 2021-05-13 13:47:15 +0200 |
---|---|---|
committer | Marvin Borner | 2021-05-13 13:47:15 +0200 |
commit | a086d68bea0004b52a78482daa9292bde6e36e8c (patch) | |
tree | 4932f50c408f2b1003155c2178954ffeebe83fd9 | |
parent | f181a8f04dfdfd8829861e0d0d549f39e40081e6 (diff) |
liblib
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | src/context.c | 4 | ||||
-rw-r--r-- | src/inc/context.h | 2 | ||||
-rw-r--r-- | src/inc/lib.h | 33 | ||||
-rw-r--r-- | src/lint.c | 2 | ||||
-rw-r--r-- | src/log.c | 4 | ||||
-rw-r--r-- | src/preprocess.c | 4 | ||||
-rw-r--r-- | src/tokenize.c | 5 |
8 files changed, 40 insertions, 16 deletions
@@ -4,7 +4,7 @@ SOURCES = $(wildcard $(SOURCEDIR)/*.c) OBJS = $(patsubst $(SOURCEDIR)/%.c, $(BUILDDIR)/%.o, $(SOURCES)) CC = gcc -CFLAGS = -Ofast -Wall -Wextra -pedantic -Wshadow -Wpointer-arith -Wwrite-strings -Wredundant-decls -Wnested-externs -Wformat=1 -Wmissing-declarations -Wstrict-prototypes -Wmissing-prototypes -Wcast-qual -Wswitch-default -Wswitch-enum -Wlogical-op -Wunreachable-code -Wundef -Wold-style-definition -Wvla -std=c99 -fsanitize=address -fsanitize=undefined -I$(SOURCEDIR)/inc/ +CFLAGS = -Ofast -Wall -Wextra -Werror -pedantic -Wshadow -Wpointer-arith -Wwrite-strings -Wredundant-decls -Wnested-externs -Wformat=1 -Wmissing-declarations -Wstrict-prototypes -Wmissing-prototypes -Wcast-qual -Wswitch-default -Wswitch-enum -Wlogical-op -Wunreachable-code -Wundef -Wold-style-definition -Wvla -std=c99 -fsanitize=address -fsanitize=undefined -I$(SOURCEDIR)/inc/ all: $(OBJS) @$(CC) -o ./$(BUILDDIR)/out $(CFLAGS) $^ diff --git a/src/context.c b/src/context.c index 3a98a64..c0898d8 100644 --- a/src/context.c +++ b/src/context.c @@ -1,7 +1,5 @@ -#include <assert.h> #include <context.h> -#include <stdio.h> -#include <stdlib.h> +#include <lib.h> #include <tokenize.h> struct ctx *context_create(const char *path) diff --git a/src/inc/context.h b/src/inc/context.h index 81a2ca4..603f42e 100644 --- a/src/inc/context.h +++ b/src/inc/context.h @@ -1,7 +1,7 @@ #ifndef CONTEXT_H #define CONTEXT_H -#include <string.h> +#include <lib.h> struct ctx { size_t line; diff --git a/src/inc/lib.h b/src/inc/lib.h new file mode 100644 index 0000000..0402990 --- /dev/null +++ b/src/inc/lib.h @@ -0,0 +1,33 @@ +#ifndef LIB_H +#define LIB_H + +// Compatibility imports (mainly for Melvix) + +#ifdef __melvix__ + +#include <arg.h> +#include <assert.h> +#include <def.h> +#include <mem.h> +#include <print.h> +#include <str.h> +#include <sys.h> +typedef size_t u32; + +#elif defined(__linux__) || defined(unix) || defined(__unix__) || defined(__unix) || \ + defined(__APPLE__) || defined(__FreeBSD) + +#include <assert.h> +#include <ctype.h> +#include <stdarg.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/param.h> + +#else +#error "Unknown operating system" +#endif + +#endif @@ -1,6 +1,6 @@ +#include <lib.h> #include <lint.h> #include <log.h> -#include <string.h> #include <tokenize.h> void lint(struct ctx *ctx) @@ -1,7 +1,5 @@ +#include <lib.h> #include <log.h> -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> static void context_print(FILE *fd, struct ctx *ctx) { diff --git a/src/preprocess.c b/src/preprocess.c index 673bd20..e721207 100644 --- a/src/preprocess.c +++ b/src/preprocess.c @@ -1,8 +1,6 @@ -#include <assert.h> +#include <lib.h> #include <log.h> #include <preprocess.h> -#include <string.h> -#include <sys/param.h> static void preprocess_erase(struct ctx *ctx, size_t start) { diff --git a/src/tokenize.c b/src/tokenize.c index 3424454..69f17c9 100644 --- a/src/tokenize.c +++ b/src/tokenize.c @@ -1,8 +1,5 @@ -#include <assert.h> -#include <ctype.h> +#include <lib.h> #include <log.h> -#include <stdbool.h> -#include <stdio.h> #include <tokenize.h> static char next_non_alnum(struct ctx *ctx, size_t start) |