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/distribution.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/solvers/distribution.h') diff --git a/src/solvers/distribution.h b/src/solvers/distribution.h index 78b9b5e..a996e3db 100644 --- a/src/solvers/distribution.h +++ b/src/solvers/distribution.h @@ -12,9 +12,9 @@ typedef struct { STATIC wrapthread_return_t getdistribution_runthread(void *); STATIC void getdistribution(const unsigned char *, - uint64_t [static INFO_DISTRIBUTION_LEN], const tableinfo_t [static 1]); -STATIC bool distribution_equal(const uint64_t [static INFO_DISTRIBUTION_LEN], - const uint64_t [static INFO_DISTRIBUTION_LEN], uint8_t); + uint64_t [SIZE(INFO_DISTRIBUTION_LEN)], const tableinfo_t [NON_NULL]); +STATIC bool distribution_equal(const uint64_t [SIZE(INFO_DISTRIBUTION_LEN)], + const uint64_t [SIZE(INFO_DISTRIBUTION_LEN)], uint8_t); STATIC wrapthread_return_t getdistribution_runthread(void *arg) @@ -39,8 +39,8 @@ getdistribution_runthread(void *arg) STATIC void getdistribution( const unsigned char *table, - uint64_t distr[static INFO_DISTRIBUTION_LEN], - const tableinfo_t info[static 1] + uint64_t distr[SIZE(INFO_DISTRIBUTION_LEN)], + const tableinfo_t info[NON_NULL] ) { getdistribution_data_t targ[THREADS]; wrapthread_define_var_thread_t(thread[THREADS]); @@ -80,8 +80,8 @@ getdistribution( STATIC bool distribution_equal( - const uint64_t expected[static INFO_DISTRIBUTION_LEN], - const uint64_t actual[static INFO_DISTRIBUTION_LEN], + const uint64_t expected[SIZE(INFO_DISTRIBUTION_LEN)], + const uint64_t actual[SIZE(INFO_DISTRIBUTION_LEN)], uint8_t maxvalue ) { -- cgit v1.3