Skip to content

Commit

Permalink
gdb_if: use #defines for max_port
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
xobs committed Nov 29, 2023
1 parent 6c61d4b commit 543ab0e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/platforms/hosted/gdb_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ 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
static const uint16_t default_port = DEFAULT_PORT;
static const uint16_t max_port = (DEFAULT_PORT + 4U);

#if defined(_WIN32) || defined(__CYGWIN__)
const int op_would_block = WSAEWOULDBLOCK;
Expand Down

0 comments on commit 543ab0e

Please sign in to comment.