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/h48/utils.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/solvers/h48/utils.h') diff --git a/src/solvers/h48/utils.h b/src/solvers/h48/utils.h index 27fb2e5..6d91108 100644 --- a/src/solvers/h48/utils.h +++ b/src/solvers/h48/utils.h @@ -4,11 +4,11 @@ #define H48_HMAX UINT8_C(7) #endif -long long parse_h48h(const char *, uint8_t [static 1]); -STATIC long long dataid_h48(const char *, char [static NISSY_SIZE_DATAID]); +long long parse_h48h(const char *, uint8_t [NON_NULL]); +STATIC long long dataid_h48(const char *, char [SIZE(NISSY_SIZE_DATAID)]); long long -parse_h48h(const char *buf, uint8_t h[static 1]) +parse_h48h(const char *buf, uint8_t h[NON_NULL]) { char format_error_msg[100]; sprintf(format_error_msg, "[H48] Error parsing H48 solver: must be in " @@ -29,7 +29,7 @@ parse_h48h(const char *buf, uint8_t h[static 1]) goto parse_h48h_error; } - *h = atoi(buf); + *h = (uint8_t)atoi(buf); if (*h > H48_HMAX) { LOG("[H48] Invalid value %" PRIu8 " for parameter h (must be " "at most %" PRIu8 ")\n", *h, H48_HMAX); @@ -51,7 +51,7 @@ parse_h48h_error: } STATIC long long -dataid_h48(const char *str, char buf[static NISSY_SIZE_DATAID]) +dataid_h48(const char *str, char buf[SIZE(NISSY_SIZE_DATAID)]) { uint8_t h; long long err; -- cgit v1.3