From ca63470cc98fc81aff52d8ff8b8707da8e8b6b67 Mon Sep 17 00:00:00 2001 From: bumbread Date: Thu, 4 Aug 2022 19:08:53 +1100 Subject: [PATCH] Compile with max warnings --- bake.cmd | 2 +- inc/stddef.h | 8 ++------ src/_win/environment.c | 20 -------------------- src/_win/stdio.c | 2 +- src/fmt/gen_fmt.h | 10 ++++------ 5 files changed, 8 insertions(+), 34 deletions(-) diff --git a/bake.cmd b/bake.cmd index 0fa144f..aec9f5e 100644 --- a/bake.cmd +++ b/bake.cmd @@ -1,4 +1,4 @@ nasm src\_win\chkstk.asm -ochkstk.o -fwin64 -clang src\ciabatta.c -o ciabatta.obj -c -DCIABATTA_WIN -I inc -I src\_win -nodefaultlibs -g -mfma +clang -Wall src\ciabatta.c -o ciabatta.obj -c -DCIABATTA_WIN -I inc -I src\_win -nodefaultlibs -g -mfma lib /nologo /out:ciabatta.lib chkstk.o ciabatta.obj src\fdec64\fdec64.lib src\unicope\unicope.lib diff --git a/inc/stddef.h b/inc/stddef.h index 1db0144..5a0fb73 100644 --- a/inc/stddef.h +++ b/inc/stddef.h @@ -1,6 +1,8 @@ #pragma once +#include + #define __bool_true_false_are_defined 1 #define __alignas_is_defined 1 #define __alignof_is_defined 1 @@ -8,12 +10,6 @@ #define NULL ((void *)0) #define offsetof(st, m) ((size_t)((char *)&((st *)0)->m - (char *)0)) -#if defined(_WIN32) - typedef unsigned long size_t; -#else - typedef unsigned long long size_t; -#endif - typedef long long ptrdiff_t; typedef long long max_align_t; typedef unsigned short wchar_t; // diff --git a/src/_win/environment.c b/src/_win/environment.c index 3674666..a358d0b 100644 --- a/src/_win/environment.c +++ b/src/_win/environment.c @@ -164,26 +164,6 @@ int _wcsicmp(wchar_t const* s1, wchar_t const* s2) { return diff; } -static size_t count_wide_chars(const wchar_t* str) { - size_t len = 0; - while (str[len] != 0) len++; - return len; -} - -static bool wchar_to_ansi(char* out, const wchar_t* str, size_t len) { - for (size_t i = 0; i < len; i++) { - wchar_t ch = *str++; - if (ch < 0 || ch > 0x7F) { - *out++ = 0; - return false; - } - *out++ = ch; - } - - *out++ = 0; - return true; -} - static int cmdline_to_argv8(const wchar_t *cmd, char **argv); static char **get_command_args(int *argc_ptr) { diff --git a/src/_win/stdio.c b/src/_win/stdio.c index d3aeff9..f170fb9 100644 --- a/src/_win/stdio.c +++ b/src/_win/stdio.c @@ -413,7 +413,7 @@ int ungetc(int c, FILE *stream) { } cum: mtx_unlock(&stream->lock); - return 0; + return res; } int fgetpos(FILE *restrict stream, fpos_t *restrict pos) { diff --git a/src/fmt/gen_fmt.h b/src/fmt/gen_fmt.h index 1f93985..4e567dd 100644 --- a/src/fmt/gen_fmt.h +++ b/src/fmt/gen_fmt.h @@ -263,7 +263,7 @@ static int pfx(vprintfcb)( double value; } _ = {.value = value}; uint64_t bits = _.bits; - uint64_t neg = bits >> 63; + // uint64_t neg = bits >> 63; int64_t e2 = (int64_t)((bits >> 52) & ((1<<11)-1)); int64_t m2 = bits & ((UINT64_C(1)<<52)-1); if(class == FP_ZERO) { @@ -352,7 +352,7 @@ static int pfx(vprintfcb)( out(' '); } // Print string - mbstate_t ps = {0}; + //mbstate_t ps = {0}; for(int i = 0; i < len; ++i) { out(str[i]); } @@ -547,7 +547,7 @@ static inline int pfx(_dtoh)( double value; } _ = {.value = value}; uint64_t bits = _.bits; - uint64_t neg = bits >> 63; + // uint64_t neg = bits >> 63; int64_t exp = (int64_t)((bits >> 52) & 0x7ff) - 1023; int64_t mant = bits & ((UINT64_C(1)<<51)-1); if(class == FP_SUBNORMAL || class == FP_ZERO) { @@ -555,7 +555,6 @@ static inline int pfx(_dtoh)( } // Figure out how many hex digits does mantissa take up (mant_digits_n) // and the number of digits after decimal point (prec) - static ctype mant_buf[64] = {0}; int mant_digits_n; int nonsig_digits_n = 0; if(mant != 0) { @@ -690,7 +689,7 @@ static inline int pfx(_dtoa)( double value; } _ = {.value = value}; uint64_t bits = _.bits; - uint64_t neg = bits >> 63; + //uint64_t neg = bits >> 63; int64_t e2 = (int64_t)((bits >> 52) & ((1<<11)-1)); int64_t m2 = bits & ((UINT64_C(1)<<52)-1); if(class == FP_ZERO) { @@ -816,7 +815,6 @@ static inline int pfx(_etoa)( double value; } _ = {.value = value}; uint64_t bits = _.bits; - uint64_t neg = bits >> 63; int64_t e2 = (int64_t)((bits >> 52) & ((1<<11)-1)); int64_t m2 = bits & ((UINT64_C(1)<<52)-1); if(class == FP_ZERO) {