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/core/cube.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 '')
| -rw-r--r-- | src/core/cube.h | 8 |
1 files changed, 4 insertions, 4 deletions
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 @@ | |||
| 1 | STATIC bool cube_true(cube_t); | 1 | STATIC bool cube_true(cube_t); |
| 2 | 2 | ||
| 3 | STATIC cube_t cubefromarray(uint8_t [static 8], uint8_t [static 12]); | 3 | STATIC cube_t cubefromarray(uint8_t [SIZE(8)], uint8_t [SIZE(12)]); |
| 4 | STATIC bool isconsistent(oriented_cube_t); | 4 | STATIC bool isconsistent(oriented_cube_t); |
| 5 | STATIC bool issolvable(oriented_cube_t); | 5 | STATIC bool issolvable(oriented_cube_t); |
| 6 | STATIC bool issolved(oriented_cube_t); | 6 | STATIC bool issolved(oriented_cube_t); |
| @@ -10,7 +10,7 @@ STATIC void getcube_fix(long long *, long long *, | |||
| 10 | STATIC cube_t getcube(uint64_t, uint64_t, uint64_t, uint64_t); | 10 | STATIC cube_t getcube(uint64_t, uint64_t, uint64_t, uint64_t); |
| 11 | 11 | ||
| 12 | STATIC oriented_cube_t readcube(const char *); | 12 | STATIC oriented_cube_t readcube(const char *); |
| 13 | STATIC int64_t writecube(oriented_cube_t, size_t n, char [n]); | 13 | STATIC int64_t writecube(oriented_cube_t, size_t n, char *); |
| 14 | STATIC uint8_t readco(const char *); | 14 | STATIC uint8_t readco(const char *); |
| 15 | STATIC uint8_t readcp(const char *); | 15 | STATIC uint8_t readcp(const char *); |
| 16 | STATIC uint8_t readeo(const char *); | 16 | STATIC uint8_t readeo(const char *); |
| @@ -29,7 +29,7 @@ cube_true(cube_t cube) | |||
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | STATIC cube_t | 31 | STATIC cube_t |
| 32 | cubefromarray(uint8_t c[static 8], uint8_t e[static 12]) | 32 | cubefromarray(uint8_t c[SIZE(8)], uint8_t e[SIZE(12)]) |
| 33 | { | 33 | { |
| 34 | return STATIC_CUBE( | 34 | return STATIC_CUBE( |
| 35 | c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], | 35 | c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7], |
| @@ -304,7 +304,7 @@ readcube(const char *buf) | |||
| 304 | } | 304 | } |
| 305 | 305 | ||
| 306 | STATIC int64_t | 306 | STATIC int64_t |
| 307 | writecube(oriented_cube_t cube, size_t buf_size, char buf[buf_size]) | 307 | writecube(oriented_cube_t cube, size_t buf_size, char *buf) |
| 308 | { | 308 | { |
| 309 | int i; | 309 | int i; |
| 310 | uint8_t corner[8], edge[12]; | 310 | uint8_t corner[8], edge[12]; |
