aboutsummaryrefslogtreecommitdiff
path: root/src/nissy.h
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.h
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.h')
-rw-r--r--src/nissy.h33
1 files changed, 22 insertions, 11 deletions
diff --git a/src/nissy.h b/src/nissy.h
index c85072a..c7edf88 100644
--- a/src/nissy.h
+++ b/src/nissy.h
@@ -149,7 +149,9 @@ Compute the inverse of the given cube.
149 149
150Parameters: 150Parameters:
151 cube - The cube to be inverted. 151 cube - The cube to be inverted.
152 Required size: NISSY_SIZE_CUBE.
152 result - The return parameter for the resulting cube. 153 result - The return parameter for the resulting cube.
154 Required size: NISSY_SIZE_CUBE.
153 155
154Return values: 156Return values:
155 NISSY_OK - The cube was inverted succesfully. 157 NISSY_OK - The cube was inverted succesfully.
@@ -161,8 +163,8 @@ Return values:
161*/ 163*/
162long long 164long long
163nissy_inverse( 165nissy_inverse(
164 const char cube[static NISSY_SIZE_CUBE], 166 const char cube[], /* NISSY_SIZE_CUBE */
165 char result[static NISSY_SIZE_CUBE] 167 char result[] /* NISSY_SIZE_CUBE */
166); 168);
167 169
168/* 170/*
@@ -170,8 +172,10 @@ Apply the given sequence of moves on the given cube.
170 172
171Parameters: 173Parameters:
172 cube - The cube to move. 174 cube - The cube to move.
175 Required size: NISSY_SIZE_CUBE.
173 moves - The moves to apply to the cube. Must be a NULL-terminated string. 176 moves - The moves to apply to the cube. Must be a NULL-terminated string.
174 result - The return parameter for the resulting cube. 177 result - The return parameter for the resulting cube.
178 Required size: NISSY_SIZE_CUBE.
175 179
176Return values: 180Return values:
177 NISSY_OK - The moves were applied succesfully. 181 NISSY_OK - The moves were applied succesfully.
@@ -184,9 +188,9 @@ Return values:
184*/ 188*/
185long long 189long long
186nissy_applymoves( 190nissy_applymoves(
187 const char cube[static NISSY_SIZE_CUBE], 191 const char cube[], /* NISSY_SIZE_CUBE */
188 const char *moves, 192 const char *moves,
189 char result[static NISSY_SIZE_CUBE] 193 char result[] /* NISSY_SIZE_CUBE */
190); 194);
191 195
192/* 196/*
@@ -194,8 +198,11 @@ Apply the single given transformation to the given cube.
194 198
195Parameters: 199Parameters:
196 cube - The cube to be transformed. 200 cube - The cube to be transformed.
201 Required size: NISSY_SIZE_CUBE.
197 transformation - The transformation in "(rotation|mirrored) __" format. 202 transformation - The transformation in "(rotation|mirrored) __" format.
203 Required size: NISSY_SIZE_TRANSFORMATION.
198 result - The return parameter for the resulting cube. 204 result - The return parameter for the resulting cube.
205 Required size: NISSY_SIZE_CUBE.
199 206
200Return values: 207Return values:
201 NISSY_OK - The transformation was performed succesfully. 208 NISSY_OK - The transformation was performed succesfully.
@@ -206,9 +213,9 @@ Return values:
206*/ 213*/
207long long 214long long
208nissy_applytrans( 215nissy_applytrans(
209 const char cube[static NISSY_SIZE_CUBE], 216 const char cube[], /* NISSY_SIZE_CUBE */
210 const char transformation[static NISSY_SIZE_TRANSFORMATION], 217 const char transformation[], /* NISSY_SIZE_TRANSFORMATION */
211 char result[static NISSY_SIZE_CUBE] 218 char result[] /* NISSY_SIZE_CUBE */
212); 219);
213 220
214/* 221/*
@@ -256,6 +263,7 @@ Parameters:
256 orient - The orientation of the cube, 0 <= orient < 24 263 orient - The orientation of the cube, 0 <= orient < 24
257 options - Other options. 264 options - Other options.
258 result - The return parameter for the resulting cube. 265 result - The return parameter for the resulting cube.
266 Required size: NISSY_SIZE_CUBE.
259 267
260Return values: 268Return values:
261 NISSY_OK - The cube was generated succesfully. 269 NISSY_OK - The cube was generated succesfully.
@@ -270,7 +278,7 @@ nissy_getcube(
270 long long co, 278 long long co,
271 long long orient, 279 long long orient,
272 const char *options, 280 const char *options,
273 char result[static NISSY_SIZE_CUBE] 281 char result[] /* NISSY_SIZE_CUBE */
274); 282);
275 283
276/* 284/*
@@ -283,6 +291,7 @@ Parameters:
283 solvers may use equivalent data. This identifier can be used 291 solvers may use equivalent data. This identifier can be used
284 e.g. as a filename or database key to save and retrieve the 292 e.g. as a filename or database key to save and retrieve the
285 correct data for each solver, without duplication. 293 correct data for each solver, without duplication.
294 Required size: NISSY_SIZE_DATAID.
286 295
287Return values: 296Return values:
288 NISSY_ERROR_INVALID_SOLVER - The given solver is not known. 297 NISSY_ERROR_INVALID_SOLVER - The given solver is not known.
@@ -293,7 +302,7 @@ Return values:
293long long 302long long
294nissy_solverinfo( 303nissy_solverinfo(
295 const char *solver, 304 const char *solver,
296 char dataid[static NISSY_SIZE_DATAID] 305 char dataid[] /* NISSY_SIZE_DATAID */
297); 306);
298 307
299/* 308/*
@@ -350,6 +359,7 @@ Solve the given cube using the given solver and options.
350 359
351Parameters: 360Parameters:
352 cube - The cube to solver. 361 cube - The cube to solver.
362 Required size: NISSY_SIZE_CUBE.
353 solver - The name of the solver. See doc/solvers.md for a list. 363 solver - The name of the solver. See doc/solvers.md for a list.
354 nissflag - The flags for NISS (linear, inverse, mixed, or 364 nissflag - The flags for NISS (linear, inverse, mixed, or
355 combinations; see the constants at the top of this file). 365 combinations; see the constants at the top of this file).
@@ -370,6 +380,7 @@ Parameters:
370 separated by a '\n' (newline) and a '\0' (NULL character) 380 separated by a '\n' (newline) and a '\0' (NULL character)
371 terminates the list. 381 terminates the list.
372 stats - An array to store some statistics about the solve. 382 stats - An array to store some statistics about the solve.
383 Required size: NISSY_SIZE_SOLVE_STATS.
373 poll_status - A callback function that should return the current 384 poll_status - A callback function that should return the current
374 requested status for the solver (e.g. run, stop, pause, 385 requested status for the solver (e.g. run, stop, pause,
375 resume; see the constants at the top of this file). The 386 resume; see the constants at the top of this file). The
@@ -391,7 +402,7 @@ Return values:
391*/ 402*/
392long long 403long long
393nissy_solve( 404nissy_solve(
394 const char cube[static NISSY_SIZE_CUBE], 405 const char cube[], /* NISSY_SIZE_CUBE */
395 const char *solver, 406 const char *solver,
396 unsigned nissflag, 407 unsigned nissflag,
397 unsigned minmoves, 408 unsigned minmoves,
@@ -403,7 +414,7 @@ nissy_solve(
403 const unsigned char *data, 414 const unsigned char *data,
404 unsigned sols_size, 415 unsigned sols_size,
405 char *sols, 416 char *sols,
406 long long stats[static NISSY_SIZE_SOLVE_STATS], 417 long long stats[], /* NISSY_SIZE_SOLVE_STATS */
407 int (*poll_status)(void *), 418 int (*poll_status)(void *),
408 void *poll_status_data 419 void *poll_status_data
409); 420);

Generated with cgit - Back to sebastiano.tronto.net