diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2026-04-06 15:55:33 +0200 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2026-04-06 15:55:33 +0200 |
| commit | fc41f7917531693680b5baf71ffe38c47333fe84 (patch) | |
| tree | a6e62232e05e7779034c5f9d1bf743b6f1c198e3 /src/solvers/h48/utils.h | |
| parent | fe534f1497da6447153064d7bba00243000f803b (diff) | |
| download | nissy-core-fc41f7917531693680b5baf71ffe38c47333fe84.tar.gz nissy-core-fc41f7917531693680b5baf71ffe38c47333fe84.zip | |
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.
Diffstat (limited to 'src/solvers/h48/utils.h')
| -rw-r--r-- | src/solvers/h48/utils.h | 10 |
1 files changed, 5 insertions, 5 deletions
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 @@ | |||
| 4 | #define H48_HMAX UINT8_C(7) | 4 | #define H48_HMAX UINT8_C(7) |
| 5 | #endif | 5 | #endif |
| 6 | 6 | ||
| 7 | long long parse_h48h(const char *, uint8_t [static 1]); | 7 | long long parse_h48h(const char *, uint8_t [NON_NULL]); |
| 8 | STATIC long long dataid_h48(const char *, char [static NISSY_SIZE_DATAID]); | 8 | STATIC long long dataid_h48(const char *, char [SIZE(NISSY_SIZE_DATAID)]); |
| 9 | 9 | ||
| 10 | long long | 10 | long long |
| 11 | parse_h48h(const char *buf, uint8_t h[static 1]) | 11 | parse_h48h(const char *buf, uint8_t h[NON_NULL]) |
| 12 | { | 12 | { |
| 13 | char format_error_msg[100]; | 13 | char format_error_msg[100]; |
| 14 | sprintf(format_error_msg, "[H48] Error parsing H48 solver: must be in " | 14 | 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]) | |||
| 29 | goto parse_h48h_error; | 29 | goto parse_h48h_error; |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | *h = atoi(buf); | 32 | *h = (uint8_t)atoi(buf); |
| 33 | if (*h > H48_HMAX) { | 33 | if (*h > H48_HMAX) { |
| 34 | LOG("[H48] Invalid value %" PRIu8 " for parameter h (must be " | 34 | LOG("[H48] Invalid value %" PRIu8 " for parameter h (must be " |
| 35 | "at most %" PRIu8 ")\n", *h, H48_HMAX); | 35 | "at most %" PRIu8 ")\n", *h, H48_HMAX); |
| @@ -51,7 +51,7 @@ parse_h48h_error: | |||
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | STATIC long long | 53 | STATIC long long |
| 54 | dataid_h48(const char *str, char buf[static NISSY_SIZE_DATAID]) | 54 | dataid_h48(const char *str, char buf[SIZE(NISSY_SIZE_DATAID)]) |
| 55 | { | 55 | { |
| 56 | uint8_t h; | 56 | uint8_t h; |
| 57 | long long err; | 57 | long long err; |
