Skip to content

Commit

Permalink
utils: iio_info: Work around MSVC not handling error codes
Browse files Browse the repository at this point in the history
MSVC does not support escape sequences and will complain if it finds
some, even when those are actually dead code.

Signed-off-by: Paul Cercueil <[email protected]>
  • Loading branch information
pcercuei committed Dec 11, 2023
1 parent 5b8a54a commit 71c069f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions utils/iio_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,19 @@ static int dev_is_buffer_capable(const struct iio_device *dev)

static bool colors;

#ifndef _MSC_BUILD
#define FMT_ERR "\e[1;31mERROR: %s\e[0m"
#define FMT_DEV "\e[1;32m%s\e[0m"
#define FMT_CHN "\e[0;33m%s\e[0m"
#define FMT_ATTR "\e[1;34m%s\e[0m"
#else
/* MSVC doesn't like escape codes. But those will never be used anyway,
* as color support is disabled when building with MSVC. */
#define FMT_ERR "%s"
#define FMT_DEV "%s"
#define FMT_CHN "%s"
#define FMT_ATTR "%s"
#endif

/* Keeps Codacy happy */
#define print_fmt(fmt, ...) printf(fmt, __VA_ARGS__) /* Flawfinder: ignore */
Expand Down

0 comments on commit 71c069f

Please sign in to comment.