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. --- src/solvers/tables.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/solvers/tables.h') diff --git a/src/solvers/tables.h b/src/solvers/tables.h index b7a1079..3db1d1e 100644 --- a/src/solvers/tables.h +++ b/src/solvers/tables.h @@ -1,17 +1,17 @@ STATIC uint64_t read_unaligned_u64( - const unsigned char [static sizeof(uint64_t)]); + const unsigned char [SIZE(sizeof(uint64_t))]); STATIC void write_unaligned_u64( - unsigned char [static sizeof(uint64_t)], uint64_t); + unsigned char [SIZE(sizeof(uint64_t))], uint64_t); STATIC int64_t readtableinfo( - size_t, const unsigned char *, tableinfo_t [static 1]); + size_t, const unsigned char *, tableinfo_t [NON_NULL]); STATIC int64_t readtableinfo_n( - size_t, const unsigned char *, uint8_t, tableinfo_t [static 1]); + size_t, const unsigned char *, uint8_t, tableinfo_t [NON_NULL]); STATIC int64_t writetableinfo( - const tableinfo_t [static 1], size_t, unsigned char *); -STATIC void append_name(tableinfo_t [static 1], const char *); + const tableinfo_t [NON_NULL], size_t, unsigned char *); +STATIC void append_name(tableinfo_t [NON_NULL], const char *); STATIC uint64_t -read_unaligned_u64(const unsigned char buf[static sizeof(uint64_t)]) +read_unaligned_u64(const unsigned char buf[SIZE(sizeof(uint64_t))]) { uint64_t ret; @@ -21,7 +21,7 @@ read_unaligned_u64(const unsigned char buf[static sizeof(uint64_t)]) } STATIC void -write_unaligned_u64(unsigned char buf[static sizeof(uint64_t)], uint64_t x) +write_unaligned_u64(unsigned char buf[SIZE(sizeof(uint64_t))], uint64_t x) { memcpy(buf, &x, sizeof(uint64_t)); } @@ -30,7 +30,7 @@ STATIC int64_t readtableinfo( size_t buf_size, const unsigned char *buf, - tableinfo_t info[static 1] + tableinfo_t info[NON_NULL] ) { size_t i; @@ -75,7 +75,7 @@ readtableinfo_n( size_t buf_size, const unsigned char *buf, uint8_t n, - tableinfo_t info[static 1] + tableinfo_t info[NON_NULL] ) { int64_t ret; @@ -89,7 +89,7 @@ readtableinfo_n( STATIC int64_t writetableinfo( - const tableinfo_t info[static 1], + const tableinfo_t info[NON_NULL], size_t data_size, unsigned char *buf ) @@ -138,9 +138,9 @@ writetableinfo( } STATIC void -append_name(tableinfo_t info[static 1], const char *str) +append_name(tableinfo_t info[NON_NULL], const char *str) { - int i, j; + size_t i, j; for (i = 0, j = strlen(info->solver); str[i] != '\0'; i++, j++) info->solver[j] = str[i]; -- cgit v1.3