Re: [PATCH] gdb: fix command_classes name clash

Guinevere Larsen
2025-11-06T11:35:23Z

On 11/5/25 7:59 PM, simon.marchi@polymtl.ca wrote:
> From: Simon Marchi <simon.marchi@polymtl.ca>
>
> I currently see this build failure:
>
> CXX guile/scm-cmd.o
> /home/simark/src/binutils-gdb/gdb/guile/scm-cmd.c:551:54: error: ‘const scheme_integer_constant command_classes []’ redeclared as different kind of entity
> 551 | static const scheme_integer_constant command_classes[] =
> | ^
> In file included from /home/simark/src/binutils-gdb/gdb/defs.h:63,
> from <command-line>:
> /home/simark/src/binutils-gdb/gdb/command.h:71:42: note: previous declaration ‘using command_classes = class enum_flags<command_class>’
> 71 | DEF_ENUM_FLAGS_TYPE (enum command_class, command_classes);
> | ^~~~~~~~~~~~~~~
> /home/simark/src/binutils-gdb/gdb/../gdbsupport/enum-flags.h:58:9: note: in definition of macro ‘DEF_ENUM_FLAGS_TYPE’
> 58 | using flags_type = enum_flags<enum_type>; \
> | ^~~~~~~~~~
>
> This looks like an unfortunate name clash. Fix it by renaming the
> variable in scm-cmd.c.
>
> Change-Id: I226b052c28eb8d09fd6840337845a387cd818085
> ---

oops, sorry about that, I disable guile on my build and didn't notice
the name clash.

I encourage you to push this! Reviewed-By: Guinevere Larsen
<guinevere@redhat.com>

> gdb/guile/scm-cmd.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/gdb/guile/scm-cmd.c b/gdb/guile/scm-cmd.c
> index d2172d986187..bfd11917df96 100644
> --- a/gdb/guile/scm-cmd.c
> +++ b/gdb/guile/scm-cmd.c
> @@ -548,7 +548,7 @@ gdbscm_parse_command_name (const char *name,
> /* NOTREACHED */
> }
>
> -static const scheme_integer_constant command_classes[] =
> +static const scheme_integer_constant scm_command_classes[] =
> {
> /* Note: alias and user are special; pseudo appears to be unused,
> and there is no reason to expose tui, I think. */
> @@ -576,9 +576,9 @@ gdbscm_valid_command_class_p (int command_class)
> {
> int i;
>
> - for (i = 0; command_classes[i].name != NULL; ++i)
> + for (i = 0; scm_command_classes[i].name != NULL; ++i)
> {
> - if (command_classes[i].value == command_class)
> + if (scm_command_classes[i].value == command_class)
> return 1;
> }
>
> @@ -903,7 +903,7 @@ gdbscm_initialize_commands (void)
> = gdbscm_make_smob_type (command_smob_name, sizeof (command_smob));
> scm_set_smob_print (command_smob_tag, cmdscm_print_command_smob);
>
> - gdbscm_define_integer_constants (command_classes, 1);
> + gdbscm_define_integer_constants (scm_command_classes, 1);
> gdbscm_define_functions (command_functions, 1);
>
> for (i = 0; i < N_COMPLETERS; ++i)
>
> base-commit: 1518f2e087d31997711fc7f4472ab382c24fa903

--
Cheers,
Guinevere Larsen
It/she