diff --git a/include/config.h b/include/config.h index 5710da4b..4d669ebf 100644 --- a/include/config.h +++ b/include/config.h @@ -152,6 +152,10 @@ #define likely(expr) (__builtin_expect(!!(expr), 1)) #define unlikely(expr) (__builtin_expect(!!(expr), 0)) +#ifdef _MSC_VER +#define sscanf sscanf_s +#endif + #ifdef FLUTTER_UI #include "base.h" #endif // FLUTTER_UI diff --git a/src/uci.cpp b/src/uci.cpp index f91e094a..4a591570 100644 --- a/src/uci.cpp +++ b/src/uci.cpp @@ -160,6 +160,25 @@ void UCI::loop(int argc, char *argv[]) Position *pos = new Position; string token, cmd; +#ifdef _MSC_VER + switch (rule.piecesCount) { + case 9: + strncpy_s(StartFEN, BUFSIZ, StartFEN9, BUFSIZ - 1); + break; + case 10: + strncpy_s(StartFEN, BUFSIZ, StartFEN10, BUFSIZ - 1); + break; + case 11: + strncpy_s(StartFEN, BUFSIZ, StartFEN11, BUFSIZ - 1); + break; + case 12: + strncpy_s(StartFEN, BUFSIZ, StartFEN12, BUFSIZ - 1); + break; + default: + assert(0); + break; + } +#else switch (rule.piecesCount) { case 9: strncpy(StartFEN, StartFEN9, BUFSIZ - 1); @@ -177,6 +196,7 @@ void UCI::loop(int argc, char *argv[]) assert(0); break; } +#endif StartFEN[BUFSIZ - 1] = '\0'; diff --git a/src/ui/flutter_app/command/command_queue.cpp b/src/ui/flutter_app/command/command_queue.cpp index e31f5a2d..cc503853 100644 --- a/src/ui/flutter_app/command/command_queue.cpp +++ b/src/ui/flutter_app/command/command_queue.cpp @@ -39,7 +39,11 @@ bool CommandQueue::write(const char *command) return false; } +#ifdef _MSC_VER + strncpy_s(commands[writeIndex], COMMAND_LENGTH, command, COMMAND_LENGTH); +#else strncpy(commands[writeIndex], command, COMMAND_LENGTH); +#endif if (readIndex == -1) { readIndex = writeIndex; @@ -60,8 +64,13 @@ bool CommandQueue::read(char *dest) return false; } +#ifdef _MSC_VER + strncpy_s(dest, 4096, (char const *)commands[readIndex], 4096); // See uci.cpp LINE_INPUT_MAX_CHAR + strncpy_s(commands[readIndex], 4096, "", COMMAND_LENGTH); +#else strncpy(dest, commands[readIndex], 4096); // See uci.cpp LINE_INPUT_MAX_CHAR strncpy(commands[readIndex], "", COMMAND_LENGTH); +#endif if (++readIndex == MAX_COMMAND_COUNT) { readIndex = 0;