From fc41f7917531693680b5baf71ffe38c47333fe84 Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Mon, 6 Apr 2026 15:55:33 +0200 Subject: Make the project build with Microsoft's broken C compiler. MSVC is not fully C11-compliant, even when compiling with /std:c11. Some changes were needed to make the codebase compatible. Notably, the notation a[static N] and a[n] for function parameters of array type is not supported, so that had to be hidden behind a macro. Atomic types are also an experimental feature, apparently, but at least they work with the correct compiler flag. One thing that MSVC does well, however, is warning on integer conversions on /W4 level. I am not sure if Clang and GCC have something similar, so I took this chance to fix some of these. --- test/013_math_digitstosumzero/digitstosumzero_tests.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'test/013_math_digitstosumzero/digitstosumzero_tests.c') diff --git a/test/013_math_digitstosumzero/digitstosumzero_tests.c b/test/013_math_digitstosumzero/digitstosumzero_tests.c index 5c93083..8df1848 100644 --- a/test/013_math_digitstosumzero/digitstosumzero_tests.c +++ b/test/013_math_digitstosumzero/digitstosumzero_tests.c @@ -1,6 +1,6 @@ #include "../test.h" -uint64_t digitstosumzero(size_t n, uint8_t [n], uint8_t); +uint64_t digitstosumzero(size_t n, uint8_t *, uint8_t); void run(void) { char str[STRLENMAX]; @@ -11,10 +11,10 @@ void run(void) { fgets(str, STRLENMAX, stdin); n = atoi(str); fgets(str, STRLENMAX, stdin); - b = atoi(str); + b = (uint8_t)atoi(str); for (i = 0; i < n; i++) { fgets(str, STRLENMAX, stdin); - a[i] = atoi(str); + a[i] = (uint8_t)atoi(str); } p = digitstosumzero(n, a, b); -- cgit v1.3