From cd32443a1a740565a49fa40c6dec968549969471 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Sat, 29 Jun 2024 13:44:58 +0200 Subject: Fix some compilation warnings on Linux --- Makefile | 4 ++-- src/badlib.h | 17 ++++++++--------- src/main.c | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index c3ab930..97a1814 100644 --- a/Makefile +++ b/Makefile @@ -26,9 +26,9 @@ BIN := $(BUILD_DIR)/$(TARGET) # Compiler and linker configuration. CC := cc -CFLAGS := -Wall -Wextra -pedantic -std=c11 -DBIN_NAME=\"$(TARGET)\" +CFLAGS := -Wall -Wextra -std=gnu11 -DBIN_NAME=\"$(TARGET)\" CFLAGS += $(INC_FLAGS) -LDFLAGS := +LDFLAGS := -lm LDLIBS := RELEASE_CFLAGS := -DNDEBUG -O2 DEBUG_CFLAGS := -DDEBUG -g -fsanitize=address,undefined diff --git a/src/badlib.h b/src/badlib.h index 25e4914..c47f2b9 100644 --- a/src/badlib.h +++ b/src/badlib.h @@ -20,7 +20,9 @@ #include #include #include -#include +#include +#include +#include // // Basic types. @@ -43,7 +45,7 @@ typedef ptrdiff_t sz; typedef uintptr_t ptrsize; typedef size_t usize; -#define KB(N) ((sz)(N)*1024) +#define KB(N) ((sz)(N) * 1024) #define MB(N) ((sz)KB(N) * 1024) #define GB(N) ((sz)MB(N) * 1024) #define TB(N) ((sz)GB(N) * 1024) @@ -287,9 +289,9 @@ buf_pop(Buf *buf, void *dst, sz size) { typedef Array Str; // Create a string object from a C literal. -#define cstr(s) \ - (Str) { \ - (u8 *)(s), LEN(s) - 1 \ +#define cstr(s) \ + (Str) { \ + .mem = (u8 *)(s), .size = LEN(s) - 1, \ } // Create a string object from a char* array. @@ -945,7 +947,7 @@ _int_eq(sz a, sz b) { return a == b; } -bool +u64 _int_hash(sz a) { return a * UINT64_C(11400714819323198485); } @@ -1235,9 +1237,6 @@ Allocator os_allocator = { .free = platform_free, }; -#include -#include - void platform_sleep(size_t microseconds) { usleep(microseconds); diff --git a/src/main.c b/src/main.c index 618d325..e14ef43 100644 --- a/src/main.c +++ b/src/main.c @@ -171,7 +171,7 @@ process_file(Str path) { array_zero(chunk.constants, 256, &bytecode_arena); array_zero(chunk.code, 0xffff, &bytecode_arena); sz n_roots = array_size(parser.nodes); - CompResult res; + CompResult res = {0}; for (sz i = 0; i < n_roots; i++) { // The parser stores the root nodes as a stack. Node *root = parser.nodes[i]; -- cgit v1.2.1