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/cube.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/core/cube.h') diff --git a/src/core/cube.h b/src/core/cube.h index 9e79dda..1c21ce1 100644 --- a/src/core/cube.h +++ b/src/core/cube.h @@ -1,6 +1,6 @@ STATIC bool cube_true(cube_t); -STATIC cube_t cubefromarray(uint8_t [static 8], uint8_t [static 12]); +STATIC cube_t cubefromarray(uint8_t [SIZE(8)], uint8_t [SIZE(12)]); STATIC bool isconsistent(oriented_cube_t); STATIC bool issolvable(oriented_cube_t); STATIC bool issolved(oriented_cube_t); @@ -10,7 +10,7 @@ STATIC void getcube_fix(long long *, long long *, STATIC cube_t getcube(uint64_t, uint64_t, uint64_t, uint64_t); STATIC oriented_cube_t readcube(const char *); -STATIC int64_t writecube(oriented_cube_t, size_t n, char [n]); +STATIC int64_t writecube(oriented_cube_t, size_t n, char *); STATIC uint8_t readco(const char *); STATIC uint8_t readcp(const char *); STATIC uint8_t readeo(const char *); @@ -29,7 +29,7 @@ cube_true(cube_t cube) } STATIC cube_t -cubefromarray(uint8_t c[static 8], uint8_t e[static 12]) +cubefromarray(uint8_t c[SIZE(8)], uint8_t e[SIZE(12)]) { return STATIC_CUBE( c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], @@ -304,7 +304,7 @@ readcube(const char *buf) } STATIC int64_t -writecube(oriented_cube_t cube, size_t buf_size, char buf[buf_size]) +writecube(oriented_cube_t cube, size_t buf_size, char *buf) { int i; uint8_t corner[8], edge[12]; -- cgit v1.3