diff --git a/include/utils/utils.h b/include/utils/utils.h index b9da4f6..dd97f91 100644 --- a/include/utils/utils.h +++ b/include/utils/utils.h @@ -132,13 +132,14 @@ extern "C" { #endif #if (defined(_WIN32) || defined(_WIN64)) +#include #define __format_printf(x, y) -#define __noreturn +#define __noreturn __declspec(noreturn) #define __weak #define __unreachable() __assume(0) #define likely(p) (p) #define unlikely(p) (p) -#define isatty _isatty +#define isatty _isatty /* from io.h */ #define fileno _fileno #else #define __format_printf(x, y) __attribute__((format(printf, x, y))) diff --git a/src/logger.c b/src/logger.c index d0c7ec0..c475bb1 100644 --- a/src/logger.c +++ b/src/logger.c @@ -3,6 +3,11 @@ * * SPDX-License-Identifier: Apache-2.0 */ + +/* To disable warnings about use of strncpy and suggestions to use the more + * secure variant strncpy_s in MSVC */ +#define _CRT_SECURE_NO_WARNINGS + #include #include #include @@ -15,6 +20,14 @@ #include +#if (defined(_WIN32) || defined(_WIN64)) +/* + * For MSVC, we are expected use _write() and the type of len is unsigned int + * instead of size_t in unix. + */ +#define write(fd, data, len) _write((fd), (data), (unsigned int)(len)) +#endif + #define RED "\x1B[31m" #define GRN "\x1B[32m" #define YEL "\x1B[33m" @@ -46,7 +59,8 @@ static const char *log_level_names[LOG_MAX_LEVEL] = { static inline void logger_log_set_color(logger_t *ctx, const char *color) { - int ret, len; + int ret; + size_t len; if (ctx->flags & LOGGER_FLAG_NO_COLORS) return;