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. --- test/140_appendsolution/appendsolution_tests.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'test/140_appendsolution/appendsolution_tests.c') diff --git a/test/140_appendsolution/appendsolution_tests.c b/test/140_appendsolution/appendsolution_tests.c index f9620ab..3f4fb15 100644 --- a/test/140_appendsolution/appendsolution_tests.c +++ b/test/140_appendsolution/appendsolution_tests.c @@ -16,12 +16,12 @@ See below for the output format. uint8_t readtrans(const char [NISSY_SIZE_TRANSFORMATION]); int64_t readmoves(const char *, size_t n, size_t m, - size_t *, size_t *, uint8_t [n], uint8_t [m]); -void solution_moves_reset(solution_moves_t [static 1]); -bool solution_list_init(solution_list_t [static 1], size_t n, char [n]); -int64_t appendsolution(const solution_moves_t [static 1], - size_t, const uint64_t *, const solution_settings_t [static 1], - solution_list_t [static 1]); + size_t *, size_t *, uint8_t *, uint8_t *); +void solution_moves_reset(solution_moves_t [NON_NULL]); +bool solution_list_init(solution_list_t [NON_NULL], size_t n, char *); +int64_t appendsolution(const solution_moves_t [NON_NULL], + size_t, const uint64_t *, const solution_settings_t [NON_NULL], + solution_list_t [NON_NULL]); void run(void) { int i, j, nnt, ntrans; @@ -39,7 +39,7 @@ void run(void) { .unniss = false, .maxmoves = 20, .maxsolutions = 100, - .optimal = -1, + .optimal = 0, }; fgets(str, STRLENMAX, stdin); @@ -48,8 +48,8 @@ void run(void) { printf("Test error reading moves\n"); return; } - moves.nmoves = nm; - moves.npremoves = np; + moves.nmoves = (uint8_t)nm; + moves.npremoves = (uint8_t)np; fgets(str, STRLENMAX, stdin); settings.unniss = (bool)atoi(str); @@ -64,7 +64,7 @@ void run(void) { } } fgets(str, STRLENMAX, stdin); - settings.orientation = atoi(str); + settings.orientation = (uint8_t)atoi(str); appendsolution(&moves, nnt, tmask, &settings, &list); -- cgit v1.3