From b800c5f66e3c220ab82478545c16a13c8300e413 Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Mon, 30 Oct 2023 09:46:20 +0800 Subject: [PATCH] gdb_if: use #defines for `max_port` The MSVC compiler is extremely picky when it comes to assigning const values. Whereas GCC will allow you to add two `const` variables, MSVC will not let you use any input variables when assigning to a global const. Work around this by using the C preprocessor to define `MAX_PORT` that includes a CPP definition of `DEFAULT_PORT`, then combine these two to assign to `max_port`. This fixes the build under MSVC. Signed-off-by: Sean Cross --- src/platforms/hosted/gdb_if.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/platforms/hosted/gdb_if.c b/src/platforms/hosted/gdb_if.c index 097fbee2d2b..583f76c6d39 100644 --- a/src/platforms/hosted/gdb_if.c +++ b/src/platforms/hosted/gdb_if.c @@ -64,8 +64,10 @@ typedef int32_t socket_t; #include "bmp_hosted.h" #include "command.h" -static const uint16_t default_port = 2000U; -static const uint16_t max_port = default_port + 4U; +#define DEFAULT_PORT 2000U +#define MAX_PORT (DEFAULT_PORT + 4U) +static const uint16_t default_port = DEFAULT_PORT; +static const uint16_t max_port = MAX_PORT; #if defined(_WIN32) || defined(__CYGWIN__) const int op_would_block = WSAEWOULDBLOCK;