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/coord/common.h | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) (limited to 'src/solvers/coord/common.h') diff --git a/src/solvers/coord/common.h b/src/solvers/coord/common.h index d154636..3a62e85 100644 --- a/src/solvers/coord/common.h +++ b/src/solvers/coord/common.h @@ -1,16 +1,16 @@ STATIC uint64_t coord_coord_generic( - const coord_t [static 1], cube_t, const unsigned char *); + const coord_t [NON_NULL], cube_t, const unsigned char *); STATIC cube_t coord_cube_generic( - const coord_t [static 1], uint64_t, const unsigned char *); + const coord_t [NON_NULL], uint64_t, const unsigned char *); STATIC bool coord_isnasty_generic( - const coord_t [static 1], uint64_t, const unsigned char *); -STATIC size_t coord_gendata_generic(const coord_t [static 1], unsigned char *); + const coord_t [NON_NULL], uint64_t, const unsigned char *); +STATIC size_t coord_gendata_generic(const coord_t [NON_NULL], unsigned char *); -STATIC bool solution_lastqt_cw(const solution_moves_t [static 1]); -STATIC bool coord_can_switch(const coord_t [static 1], const unsigned char *, +STATIC bool solution_lastqt_cw(const solution_moves_t [NON_NULL]); +STATIC bool coord_can_switch(const coord_t [NON_NULL], const unsigned char *, size_t, const uint8_t *); STATIC bool coord_is_solved( - const coord_t [static 1], uint64_t, const unsigned char *); + const coord_t [NON_NULL], uint64_t, const unsigned char *); STATIC cube_t coordinate_merge_ce(cube_t, cube_t); STATIC cube_t coordinate_merge_ec(cube_t, cube_t); @@ -18,7 +18,7 @@ STATIC cube_t coordinate_merge_cpco(cube_t, cube_t); STATIC uint64_t coord_coord_generic( - const coord_t coord[static 1], + const coord_t coord[NON_NULL], cube_t c, const unsigned char *data ) @@ -36,7 +36,7 @@ coord_coord_generic( STATIC cube_t coord_cube_generic( - const coord_t coord[static 1], + const coord_t coord[NON_NULL], uint64_t i, const unsigned char *data ) @@ -54,7 +54,7 @@ coord_cube_generic( STATIC bool coord_isnasty_generic( - const coord_t coord[static 1], + const coord_t coord[NON_NULL], uint64_t i, const unsigned char *data ) @@ -73,11 +73,12 @@ coord_isnasty_generic( STATIC size_t coord_gendata_generic( - const coord_t coord[static 1], + const coord_t coord[NON_NULL], unsigned char *data ) { - uint64_t i, j, n, t, nasty; + uint64_t i, j, n, nasty; + uint8_t t; unsigned char *datanoinfo; uint32_t *classttrep, *rep; size_t coord_datasize; @@ -122,16 +123,17 @@ coord_gendata_generic( } for (t = 0; t < NTRANS; t++) { - if (!((UINT64_C(1) << t) & coord->trans_mask)) + if (!((UINT64_C(1) << (uint64_t)t) & coord->trans_mask)) continue; j = coord->sym.coord(transform(c, t)); - classttrep[j] = + classttrep[j] = (uint32_t)( (n << COORD_CLASS_SHIFT) | (nasty << COORD_ISNASTY_SHIFT) | - (inverse_trans(t) << COORD_TTREP_SHIFT); + (inverse_trans(t) << COORD_TTREP_SHIFT) + ); } - rep[n++] = i; + rep[n++] = (uint32_t)i; } writetableinfo(&info, coord_datasize, data); @@ -144,21 +146,21 @@ coord_gendata_generic( } STATIC bool -solution_lastqt_cw(const solution_moves_t s[static 1]) +solution_lastqt_cw(const solution_moves_t s[NON_NULL]) { return are_lastmoves_singlecw(s->nmoves, s->moves) && are_lastmoves_singlecw(s->npremoves, s->premoves); } STATIC bool -solution_always_valid(const solution_moves_t s[static 1]) +solution_always_valid(const solution_moves_t s[NON_NULL]) { return true; } STATIC bool coord_can_switch( - const coord_t coord[static 1], + const coord_t coord[NON_NULL], const unsigned char *data, size_t n, const uint8_t *moves @@ -192,7 +194,7 @@ coord_can_switch( STATIC bool coord_is_solved( - const coord_t coord[static 1], + const coord_t coord[NON_NULL], uint64_t i, const unsigned char *data ) -- cgit v1.3