aboutsummaryrefslogtreecommitdiff
path: root/src/nissy.c
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2026-04-06 15:55:33 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2026-04-06 15:55:33 +0200
commitfc41f7917531693680b5baf71ffe38c47333fe84 (patch)
treea6e62232e05e7779034c5f9d1bf743b6f1c198e3 /src/nissy.c
parentfe534f1497da6447153064d7bba00243000f803b (diff)
downloadnissy-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/nissy.c')
-rw-r--r--src/nissy.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/nissy.c b/src/nissy.c
index 594bdc4..0811861 100644
--- a/src/nissy.c
+++ b/src/nissy.c
@@ -12,8 +12,8 @@
12#include "core/core.h" 12#include "core/core.h"
13#include "solvers/solvers.h" 13#include "solvers/solvers.h"
14 14
15STATIC long long write_result(oriented_cube_t, char [static NISSY_SIZE_CUBE]); 15STATIC long long write_result(oriented_cube_t, char [SIZE(NISSY_SIZE_CUBE)]);
16STATIC long long nissy_dataid(const char *, char [static NISSY_SIZE_DATAID]); 16STATIC long long nissy_dataid(const char *, char [SIZE(NISSY_SIZE_DATAID)]);
17STATIC long long nissy_gendata_unsafe( 17STATIC long long nissy_gendata_unsafe(
18 const char *, unsigned long long, unsigned char *); 18 const char *, unsigned long long, unsigned char *);
19 19
@@ -28,7 +28,7 @@ struct {
28}; 28};
29 29
30STATIC long long 30STATIC long long
31write_result(oriented_cube_t cube, char result[static NISSY_SIZE_CUBE]) 31write_result(oriented_cube_t cube, char result[SIZE(NISSY_SIZE_CUBE)])
32{ 32{
33 writecube(cube, NISSY_SIZE_CUBE, result); 33 writecube(cube, NISSY_SIZE_CUBE, result);
34 34
@@ -42,8 +42,8 @@ write_result(oriented_cube_t cube, char result[static NISSY_SIZE_CUBE])
42 42
43long long 43long long
44nissy_inverse( 44nissy_inverse(
45 const char cube[static NISSY_SIZE_CUBE], 45 const char cube[],
46 char result[static NISSY_SIZE_CUBE] 46 char result[]
47) 47)
48{ 48{
49 oriented_cube_t c, res; 49 oriented_cube_t c, res;
@@ -77,9 +77,9 @@ nissy_inverse_error:
77 77
78long long 78long long
79nissy_applymoves( 79nissy_applymoves(
80 const char cube[static NISSY_SIZE_CUBE], 80 const char cube[],
81 const char *moves, 81 const char *moves,
82 char result[static NISSY_SIZE_CUBE] 82 char result[]
83) 83)
84{ 84{
85 oriented_cube_t c, res; 85 oriented_cube_t c, res;
@@ -116,9 +116,9 @@ nissy_applymoves_error:
116 116
117long long 117long long
118nissy_applytrans( 118nissy_applytrans(
119 const char cube[static NISSY_SIZE_CUBE], 119 const char cube[],
120 const char transformation[static NISSY_SIZE_TRANSFORMATION], 120 const char transformation[],
121 char result[static NISSY_SIZE_CUBE] 121 char result[]
122) 122)
123{ 123{
124 oriented_cube_t c, res; 124 oriented_cube_t c, res;
@@ -181,7 +181,7 @@ nissy_getcube(
181 long long co, 181 long long co,
182 long long orient, 182 long long orient,
183 const char *options, 183 const char *options,
184 char result[static NISSY_SIZE_CUBE] 184 char result[]
185) 185)
186{ 186{
187 int i; 187 int i;
@@ -197,7 +197,7 @@ nissy_getcube(
197 getcube_options[i].fix(&ep, &eo, &cp, &co, &orient); 197 getcube_options[i].fix(&ep, &eo, &cp, &co, &orient);
198 198
199 oc.cube = getcube(ep, eo, cp, co); 199 oc.cube = getcube(ep, eo, cp, co);
200 oc.orientation = orient; 200 oc.orientation = (uint8_t)orient;
201 201
202 if (!isconsistent(oc)) { 202 if (!isconsistent(oc)) {
203 LOG("[getcube] Error: could not get cube with ep=%lld, " 203 LOG("[getcube] Error: could not get cube with ep=%lld, "
@@ -210,7 +210,7 @@ nissy_getcube(
210} 210}
211 211
212STATIC long long 212STATIC long long
213nissy_dataid(const char *solver, char dataid[static NISSY_SIZE_DATAID]) 213nissy_dataid(const char *solver, char dataid[SIZE(NISSY_SIZE_DATAID)])
214{ 214{
215 solver_dispatch_t dispatch; 215 solver_dispatch_t dispatch;
216 216
@@ -226,7 +226,7 @@ nissy_dataid(const char *solver, char dataid[static NISSY_SIZE_DATAID])
226long long 226long long
227nissy_solverinfo( 227nissy_solverinfo(
228 const char *solver, 228 const char *solver,
229 char dataid[static NISSY_SIZE_DATAID] 229 char dataid[]
230) 230)
231{ 231{
232 long long err; 232 long long err;
@@ -295,7 +295,7 @@ nissy_checkdata(
295 295
296long long 296long long
297nissy_solve( 297nissy_solve(
298 const char cube[static NISSY_SIZE_CUBE], 298 const char cube[],
299 const char *solver, 299 const char *solver,
300 unsigned nissflag, 300 unsigned nissflag,
301 unsigned minmoves, 301 unsigned minmoves,
@@ -307,7 +307,7 @@ nissy_solve(
307 const unsigned char *data, 307 const unsigned char *data,
308 unsigned sols_size, 308 unsigned sols_size,
309 char *sols, 309 char *sols,
310 long long stats[static NISSY_SIZE_SOLVE_STATS], 310 long long stats[],
311 int (*poll_status)(void *), 311 int (*poll_status)(void *),
312 void *poll_status_data 312 void *poll_status_data
313) 313)

Generated with cgit - Back to sebastiano.tronto.net