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/core/moves.h | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'src/core/moves.h') diff --git a/src/core/moves.h b/src/core/moves.h index 6169c6e..9f1f7cc 100644 --- a/src/core/moves.h +++ b/src/core/moves.h @@ -4,15 +4,15 @@ STATIC uint8_t readmove(char); STATIC int64_t readmoves(const char *, size_t, size_t, size_t *, size_t *, uint8_t *, uint8_t *); -STATIC int64_t readmoves_struct(const char *, moves_struct_t [static 1]); +STATIC int64_t readmoves_struct(const char *, moves_struct_t [NON_NULL]); STATIC int64_t countmoves(const char *); STATIC bool moves_struct_equal( - const moves_struct_t [static 1], const moves_struct_t [static 1]); + const moves_struct_t [NON_NULL], const moves_struct_t [NON_NULL]); STATIC long long comparemoves(const char *, const char *); STATIC uint8_t readmodifier(char); STATIC int64_t writemoves(size_t, const uint8_t *, size_t, char *); STATIC int64_t writemoves_struct( - const moves_struct_t [static 1], size_t, char *); + const moves_struct_t [NON_NULL], size_t, char *); STATIC_INLINE bool allowednextmove(uint8_t, uint8_t); STATIC bool allowedmoves(size_t, const uint8_t *); @@ -36,9 +36,9 @@ STATIC bool are_lastmoves_singlecw(size_t, const uint8_t*); STATIC int64_t move_variations(const char *, const char *, size_t, char *); STATIC int64_t move_variations_lastqt( - const moves_struct_t [static 1], size_t, char *); + const moves_struct_t [NON_NULL], size_t, char *); STATIC int64_t move_variations_unniss( - const moves_struct_t [static 1], size_t, char *); + const moves_struct_t [NON_NULL], size_t, char *); #define FOREACH_READMOVE(ARG_BUF, ARG_MOVE, ARG_C, ARG_MAX, \ RET_ERROR, ARG_ACTION) \ @@ -167,7 +167,7 @@ readmoves( } STATIC int64_t -readmoves_struct(const char *moves, moves_struct_t ret[static 1]) +readmoves_struct(const char *moves, moves_struct_t ret[NON_NULL]) { return readmoves(moves, NISSY_SIZE_MOVES, NISSY_SIZE_MOVES, &ret->nnormal, &ret->ninverse, ret->normal, ret->inverse); @@ -190,8 +190,8 @@ countmoves(const char *buf) STATIC bool moves_struct_equal( - const moves_struct_t ms1[static 1], - const moves_struct_t ms2[static 1] + const moves_struct_t ms1[NON_NULL], + const moves_struct_t ms2[NON_NULL] ) { size_t i; @@ -281,7 +281,7 @@ writemoves_error: STATIC int64_t writemoves_struct( - const moves_struct_t moves[static 1], + const moves_struct_t moves[NON_NULL], size_t buf_size, char *buf ) @@ -612,7 +612,7 @@ move_variations( STATIC int64_t move_variations_lastqt( - const moves_struct_t s[static 1], + const moves_struct_t s[NON_NULL], size_t result_size, char *result ) @@ -623,10 +623,10 @@ move_variations_lastqt( size_t u; moves_struct_t ss; - in1 = s->nnormal-1; - in2 = s->nnormal-2; - ii1 = s->ninverse-1; - ii2 = s->ninverse-2; + in1 = (uint8_t)(s->nnormal-1); + in2 = (uint8_t)(s->nnormal-2); + ii1 = (uint8_t)(s->ninverse-1); + ii2 = (uint8_t)(s->ninverse-2); n1 = in1 >= 0 ? s->normal[in1] : UINT8_ERROR; n2 = in2 >= 0 ? s->normal[in2] : UINT8_ERROR; @@ -686,7 +686,7 @@ lastqt_error: STATIC int64_t move_variations_unniss( - const moves_struct_t s[static 1], + const moves_struct_t s[NON_NULL], size_t result_size, char *result ) -- cgit v1.3