From: Tom de Vries Date: Fri, 7 Feb 2025 14:57:24 +0000 (+0100) Subject: [gdb/build] Fix x86_64-w64-mingw32 build by avoiding SCNx8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4fed821ed67c3fb4c57aa43926cf5b1a02a25ccd;p=thirdparty%2Fbinutils-gdb.git [gdb/build] Fix x86_64-w64-mingw32 build by avoiding SCNx8 With an x86_64-w64-mingw32 targeted cross-build on x86_64-linux, I run into: ... gdb/cli/cli-decode.c: \ In function 'ui_file_style::color parse_cli_var_color(const char**)': gdb/cli/cli-decode.c:2917:41: error: expected ')' before 'SCNx8' int parsed_args = sscanf (*args, "#%2" SCNx8 "%2" SCNx8 "%2" SCNx8 "%n", ... Apparantly, the definition of SCNx8 is missing in inttypes.h. Rewrite the sscanf call to use SCNx32, which is available. Tested by: - completing aforementioned cross-build, and - build & test on x86_64-linux. Suggested-By: Tom Tromey Approved-By: Tom Tromey --- diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index c5eab2f4437..e5de7024ebc 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -2912,14 +2912,20 @@ parse_cli_var_color (const char **args) if (len != 7) error_no_arg (_("invalid RGB hex triplet format")); + uint32_t rgb; uint8_t r, g, b; int scanned_chars = 0; - int parsed_args = sscanf (*args, "#%2" SCNx8 "%2" SCNx8 "%2" SCNx8 "%n", - &r, &g, &b, &scanned_chars); + int parsed_args = sscanf (*args, "#%6" SCNx32 "%n", + &rgb, &scanned_chars); - if (parsed_args != 3 || scanned_chars != 7) + if (parsed_args != 1 || scanned_chars != 7) error_no_arg (_("invalid RGB hex triplet format")); + gdb_assert ((rgb >> 24) == 0); + r = (rgb >> 16) & 0xff; + g = (rgb >> 8) & 0xff; + b = rgb & 0xff; + *args += len; return ui_file_style::color (r, g, b); }